From 7f3c34178b9ac801fac232bd4758ac3e25c55fb8 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Fri, 5 Sep 2025 19:32:42 +0800 Subject: [PATCH 1/2] fix: add left-click check for tree button handlers --- apps/client/src/widgets/note_tree.ts | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.ts index 248bf0a3a..2bbee7b36 100644 --- a/apps/client/src/widgets/note_tree.ts +++ b/apps/client/src/widgets/note_tree.ts @@ -219,21 +219,22 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { this.$tree = this.$widget.find(".tree"); this.$treeActions = this.$widget.find(".tree-actions"); - this.$tree.on("mousedown", ".unhoist-button", () => hoistedNoteService.unhoist()); - this.$tree.on("mousedown", ".refresh-search-button", (e) => this.refreshSearch(e)); - this.$tree.on("mousedown", ".add-note-button", (e) => { - const node = $.ui.fancytree.getNode(e as unknown as Event); - const parentNotePath = treeService.getNotePath(node); + this.$tree.on("mousedown", (e: JQuery.MouseDownEvent) => { + const target = e.target as HTMLElement; + if (e.button !== 0) return; - noteCreateService.createNote(parentNotePath, { - isProtected: node.data.isProtected - }); - }); - - this.$tree.on("mousedown", ".enter-workspace-button", (e) => { - const node = $.ui.fancytree.getNode(e as unknown as Event); - - this.triggerCommand("hoistNote", { noteId: node.data.noteId }); + if (target.classList.contains("unhoist-button")) { + hoistedNoteService.unhoist(); + } else if (target.classList.contains("refresh-search-button")) { + this.refreshSearch(e); + } else if (target.classList.contains("add-note-button")) { + const node = $.ui.fancytree.getNode(e as unknown as Event); + const parentNotePath = treeService.getNotePath(node); + noteCreateService.createNote(parentNotePath, { isProtected: node.data.isProtected }); + } else if (target.classList.contains("enter-workspace-button")) { + const node = $.ui.fancytree.getNode(e as unknown as Event); + this.triggerCommand("hoistNote", { noteId: node.data.noteId }); + } }); // fancytree doesn't support middle click, so this is a way to support it From 2f93af4d6fdb89ba0773385c646db817ded2bf29 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Sun, 7 Sep 2025 17:15:09 +0800 Subject: [PATCH 2/2] fix: close context menu when clicking items with submenus --- apps/client/src/menus/context_menu.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/client/src/menus/context_menu.ts b/apps/client/src/menus/context_menu.ts index 4411db9dc..ef477c576 100644 --- a/apps/client/src/menus/context_menu.ts +++ b/apps/client/src/menus/context_menu.ts @@ -62,7 +62,7 @@ class ContextMenu { if (this.isMobile) { this.$cover.on("click", () => this.hide()); } else { - $(document).on("click", (e) => this.hide()); + $(document).on("mouseup", (e) => this.hide()); } } @@ -225,9 +225,10 @@ class ContextMenu { $item.on("mouseup", (e) => { // Prevent submenu from failing to expand on mobile if (!this.isMobile || !("items" in item && item.items)) { - e.stopPropagation(); // Hide the content menu on mouse up to prevent the mouse event from propagating to the elements below. - this.hide(); + if (("command" in item) || ("handler" in item)) { + this.hide(); + } return false; } });