Skip to content

fix(client): refresh the Markdown preview on note switch - #11895

Merged
eliandoran merged 4 commits into
TriliumNext:mainfrom
drakeo338:claude/11894-fix
Oct 5, 2026
Merged

eliandoran merged 4 commits into
TriliumNext:mainfrom
drakeo338:claude/11894-fix

Conversation

@drakeo338

Copy link
Copy Markdown
Contributor

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.tsx fails on the unfixed source and passes with the fix.

…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.
@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Fixes Markdown preview refresh when switching between notes.

The PR appears safe to merge.

Summary

The PR refreshes Markdown preview content when a note is loaded into a hidden editor and adds tests for hidden and visible editor loads.

Reviews (3) · Last reviewed commit: "test(client): build the EditableCode spe..."

drakeo338 and others added 3 commits October 5, 2026 10:15
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]>
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🖥️ App preview is ready!

🔗 Preview URL: https://pr-11895.trilium-app.pages.dev
📖 Production URL: https://app.triliumnotes.org

✅ All checks passed

This preview will be updated automatically with new commits.

@codecov

codecov Bot commented Oct 5, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 38 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
client-esm 41.62MB 38 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: standalone-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/src-*.js 2.06MB 2.13MB 3077.63% ⚠️
assets/src-*.js 65.39kB 67.04kB 3948.43% ⚠️
assets/src-*.js -2.13MB 1.66kB -99.92%
src/dist-*.js 1 bytes 57 bytes 1.79%
src/dist-*.js -7 bytes 56 bytes -11.11%
src/dist-*.js 6 bytes 63 bytes 10.53% ⚠️
assets/markdown-*.js -1.81kB 343 bytes -84.08%
assets/markdown-*.js 1.81kB 2.15kB 527.99% ⚠️
assets/pt-*.js 16 bytes 1.3kB 1.24%
assets/pt-*.js -16 bytes 1.29kB -1.23%
assets/__vite-*.js 74 bytes 184 bytes 67.27% ⚠️
assets/__vite-*.js -74 bytes 110 bytes -40.22%
view changes for bundle: client-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
src/dist-*.js -1 bytes 56 bytes -1.75%
src/dist-*.js 1 bytes 57 bytes 1.79%
src/Code-*.js 38 bytes 161.75kB 0.02%

Files in src/Code-*.js:

  • ./src/widgets/type_widgets/code/Code.tsx → Total Size: 7.27kB

@codecov

codecov Bot commented Oct 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/client/src/widgets/type_widgets/code/Code.tsx 50.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@eliandoran eliandoran added this to the v0.107.0 milestone Oct 5, 2026
@eliandoran
eliandoran merged commit 0d9916d into TriliumNext:main Oct 5, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content not reloaded when switching between markdown notes with preview mode enabled

2 participants