Skip to content

Build your personal knowledge base with Trilium Notes

fix: add left-click check for tree button handlers

SiriusXT7f3c34178b9a
diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.ts
index 248bf0a3ae..2bbee7b36a 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);
-
- 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 });
+ this.$tree.on("mousedown", (e: JQuery.MouseDownEvent) => {
+ const target = e.target as HTMLElement;
+ if (e.button !== 0) return;
+
+ 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