Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
better activation behavior when move notes
zadam5024454914ec
diff --git a/src/public/javascripts/widgets/note_tree.js b/src/public/javascripts/widgets/note_tree.jsindex 5471189ce7..9f198c1581 100644--- a/src/public/javascripts/widgets/note_tree.js+++ b/src/public/javascripts/widgets/note_tree.js@@ -460,6 +460,10 @@ export default class NoteTreeWidget extends TabAwareWidget {}async entitiesReloadedEvent({loadResults}) {+ const activeNode = this.getActiveNode();+ const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null;+ const activeNoteId = activeNode ? activeNode.data.noteId : null;+const noteIdsToUpdate = new Set();const noteIdsToReload = new Set();@@ -515,9 +519,6 @@ export default class NoteTreeWidget extends TabAwareWidget {}}- const activeNode = this.getActiveNode();- const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null;-for (const noteId of loadResults.getNoteIds()) {noteIdsToUpdate.add(noteId);}@@ -554,9 +555,20 @@ export default class NoteTreeWidget extends TabAwareWidget {}if (activeNotePath) {- const node = await this.expandToNote(activeNotePath);+ let node = await this.expandToNote(activeNotePath);++ if (node.data.noteId !== activeNoteId) {+ // if the active note has been moved elsewhere then it won't be found by the path+ // so we switch to the alternative of trying to find it by noteId+ const notesById = this.getNodesByNoteId(activeNoteId);- node.setActive(true, {noEvents: true});+ // if there are multiple clones then we'd rather not activate any one+ node = notesById.length === 1 ? notesById[0] : null;+ }++ if (node) {+ node.setActive(true, {noEvents: true});+ }}}diff --git a/src/routes/api/branches.js b/src/routes/api/branches.jsindex ea275c0d4e..6917f5981b 100644--- a/src/routes/api/branches.js+++ b/src/routes/api/branches.js@@ -32,6 +32,7 @@ async function moveBranchToParent(req) {const newNotePos = maxNotePos === null ? 0 : maxNotePos + 10;const newBranch = branchToMove.createClone(parentNoteId, newNotePos);+ newBranch.isExpanded = true;await newBranch.save();branchToMove.isDeleted = true;