feat: add handler for removing elements with destroy-on-click class upon clicking anywhere else on the screen
This commit is contained in:
parent
569bca810e
commit
6cec8e92b3
1 changed files with 7 additions and 0 deletions
7
app.vue
7
app.vue
|
@ -25,6 +25,13 @@ onMounted(() => {
|
|||
if (e.target instanceof HTMLElement && e.target.classList.contains("message-text") && e.target.contentEditable) {
|
||||
e.target.contentEditable = "false";
|
||||
}
|
||||
const destroyOnClick = document.getElementsByClassName("destroy-on-click");
|
||||
for (const element of destroyOnClick) {
|
||||
const closest = (e.target as HTMLElement).closest(".destroy-on-click");
|
||||
if (element != closest) {
|
||||
unrender(element);
|
||||
}
|
||||
}
|
||||
});
|
||||
document.addEventListener("keyup", (e) => {
|
||||
const messageReply = document.getElementById("message-reply") as HTMLDivElement;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue