Skip to content

Build your personal knowledge base with Trilium Notes

fix(text): dispose previous include render before replacing it

Elian Doran35cecb86b93e
diff --git a/apps/client/src/widgets/type_widgets/text/utils.ts b/apps/client/src/widgets/type_widgets/text/utils.ts
index db5dc48b14..c1041bd48e 100644
--- a/apps/client/src/widgets/type_widgets/text/utils.ts
+++ b/apps/client/src/widgets/type_widgets/text/utils.ts
@@ -48,6 +48,10 @@ export async function loadIncludedNote(noteId: string, $el: JQuery<HTMLElement>,
$wrapper.append($(`<div class="include-note-content type-${type}">`).append($renderedContent));
}
+ // Unmount any interactive widgets from a previous render of this include (e.g. on a box-size
+ // change or refreshIncludedNote) before $el.empty() discards their DOM — otherwise their
+ // standalone Preact roots (collections, web views) would leak.
+ content_renderer.disposeInteractiveContent($el);
$el.empty().append($wrapper);
}