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
fix(tree): random exceptions when switching between two spotlighted notes
Elian Doran0b40b4231508
diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.tsindex 8b43312f1d..de73efeaaf 100644--- a/apps/client/src/widgets/note_tree.ts+++ b/apps/client/src/widgets/note_tree.ts@@ -1058,7 +1058,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {}findChildNode(parentNode: Fancytree.FancytreeNode, childNoteId: string) {- return parentNode.getChildren().find((childNode) => childNode.data.noteId === childNoteId);+ return parentNode.getChildren()?.find((childNode) => childNode.data.noteId === childNoteId);}async expandToNote(notePath: string, logErrors = true) {@@ -1100,7 +1100,10 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {(await this.getNodeFromPath(this.noteContext.notePath));if (this.spotlightedNode && newActiveNode !== this.spotlightedNode) {- this.spotlightedNode.remove();+ // Can get removed when switching to another note in a spotlighted subtree.+ if (this.spotlightedNode.parent) {+ this.spotlightedNode.remove();+ }this.spotlightedNode = null;this.spotlightedNotePath = null;}