From 0b40b4231508e614995d3a0e023b7506f3277383 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 10 Jan 2026 00:42:24 +0200 Subject: [PATCH] fix(tree): random exceptions when switching between two spotlighted notes --- apps/client/src/widgets/note_tree.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.ts index 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; }