From bea39f37ee2332e753055d77aa4c1b3a9c69cdea Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 13 Jun 2023 00:12:55 +0200 Subject: [PATCH] stop click propagation in tree item actions --- package-lock.json | 4 ++-- src/public/app/widgets/note_tree.js | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 14cc4892b..8d9b63fc7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "trilium", - "version": "0.60.1-beta", + "version": "0.60.2-beta", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "trilium", - "version": "0.60.1-beta", + "version": "0.60.2-beta", "hasInstallScript": true, "license": "AGPL-3.0-only", "dependencies": { diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 60f7b34a3..1d8f426f2 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -148,6 +148,9 @@ const TPL = ` const MAX_SEARCH_RESULTS_IN_TREE = 100; +// this has to be hanged on the actual elements to effectively intercept and stop click event +const cancelClickPropagation = e => e.stopPropagation(); + export default class NoteTreeWidget extends NoteContextAwareWidget { constructor() { super(); @@ -559,7 +562,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { const isHoistedNote = activeNoteContext && activeNoteContext.hoistedNoteId === note.noteId && note.noteId !== 'root'; if (isHoistedNote) { - const $unhoistButton = $(''); + const $unhoistButton = $('') + .on("click", cancelClickPropagation); // unhoist button is prepended since compared to other buttons this is not just convenience // on the mobile interface - it's the only way to unhoist @@ -567,19 +571,22 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { } if (note.hasLabel('workspace') && !isHoistedNote) { - const $enterWorkspaceButton = $(''); + const $enterWorkspaceButton = $('') + .on("click", cancelClickPropagation); $span.append($enterWorkspaceButton); } if (note.type === 'search') { - const $refreshSearchButton = $(''); + const $refreshSearchButton = $('') + .on("click", cancelClickPropagation); $span.append($refreshSearchButton); } if (!['search', 'launcher'].includes(note.type) && !note.isOptions() && !note.isLaunchBarConfig()) { - const $createChildNoteButton = $(''); + const $createChildNoteButton = $('') + .on("click", cancelClickPropagation); $span.append($createChildNoteButton); }