Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): report a code note load only from a hidden editor

Elian Dorancf71bf1613d0
diff --git a/apps/client/src/widgets/type_widgets/code/Code.tsx b/apps/client/src/widgets/type_widgets/code/Code.tsx
index 9ac613d4ee..b457b06c4b 100644
--- a/apps/client/src/widgets/type_widgets/code/Code.tsx
+++ b/apps/client/src/widgets/type_widgets/code/Code.tsx
@@ -115,7 +115,10 @@ export function EditableCode({ note, ntxId, noteContext, debounceUpdate, parentC
const codeEditor = editorRef.current;
if (!codeEditor) return;
codeEditor.setText(content ?? "");
- onContentChanged?.(content ?? "");
+ // `setText()` loads a hidden editor without an update, so its listener reports nothing.
+ if (codeEditor.dom.offsetParent === null) {
+ onContentChanged?.(content ?? "");
+ }
codeEditor.setMimeType(note.mime);
codeEditor.clearHistory();