Repository navigation
fix(client): refresh the Markdown preview on note switch - #11895
Conversation
…iumNext#11894) Once the editor of a preview-only Markdown note has been shown, it stays mounted but hidden and feeds the preview. `setText()` replaces the state of a hidden editor with `setState()`, which fires no update listener, so `onContentChanged` never ran when another note's content was loaded and the preview kept the previous note's HTML. `EditableCode` now calls `onContentChanged` itself after loading the content.
|
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: drakeo338 <[email protected]>
A visible editor's `setText()` dispatches a transaction, and the CodeMirror update listener in `EditableCode` already passes the new content to `onContentChanged`. Calling it again after every load made `SvgSplitEditor` render each Mermaid or other diagram note twice on open. Only a hidden editor, which `setText()` fills through `setState()` without an update, needs the explicit call, so it now runs only when the editor's `offsetParent` is `null`, the same test `setText()` uses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The notes come from `buildNote()` instead of a hand-rolled object cast to `any`, and `renderInto()` tears the container down, so the spec needs no `afterEach` cleanup of its own. jsdom has no layout, so the first test loads into an editor that counts as hidden; it fails at the first load without the fix. A second test pins `offsetParent` to make the editor visible and checks that a load reports exactly once. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🖥️ App preview is ready! 🔗 Preview URL: https://pr-11895.trilium-app.pages.dev ✅ All checks passed This preview will be updated automatically with new commits. |
Bundle ReportChanges will increase total bundle size by 38 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: standalone-esmAssets Changed:
view changes for bundle: client-esmAssets Changed:
Files in
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Fixes #11894.
In a Markdown note's preview mode, switching to another Markdown note updated the title but left the previous note's rendered content. The preview is fed by the editor's content-changed callback, and the load path that fills the editor with the new note's text never called it, so the preview kept the old content. The change calls that callback after the text is set. A new test in
Code.spec.tsxfails on the unfixed source and passes with the fix.