feat: remove context menu on global mousedown only if the context menu useState variable's show value is set to true

This commit is contained in:
SauceyRed 2025-08-07 08:57:02 +02:00
parent 46a135de22
commit e5bdf63f2a
Signed by: sauceyred
GPG key ID: 2BF92EB6D8A5CCA7

View file

@ -23,11 +23,14 @@ onMounted(() => {
contextMenuHandler(e);
});
document.addEventListener("mousedown", (e) => {
if (e.target instanceof HTMLElement && e.target.closest("#context-menu")) return;
if (e.target instanceof HTMLElement && e.target.classList.contains("context-menu-item")) return;
console.log("click");
console.log("target:", e.target);
console.log(e.target instanceof HTMLDivElement);
removeContextMenu(contextMenu);
if (contextMenu.value.show) {
console.log("context menu is shown, hiding");
removeContextMenu(contextMenu);
}
if (e.target instanceof HTMLElement && e.target.classList.contains("message-text") && e.target.contentEditable) {
e.target.contentEditable = "false";
}