Skip to content

fix: sync code editor content on prop changes - #12885

Merged
tiensonqin merged 1 commit into
masterfrom
fix/code-sidebar-sync
Jul 15, 2026
Merged

fix: sync code editor content on prop changes#12885
tiensonqin merged 1 commit into
masterfrom
fix/code-sidebar-sync

Conversation

@megayu

@megayu megayu commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a UI sync bug where CodeMirror-backed code blocks (notably calc) didn’t update their displayed editor text when the code prop changed (e.g., same block open in page + sidebar), even though derived calc results could update.

Changes:

  • Add a small sync-editor-code! helper to push updated code prop into the existing CodeMirror instance when it’s not focused.
  • Avoid eagerly evaluating calc lines for non-calc blocks by deriving calc? once and lazily initializing calc state.
  • Simplify repeated "calc" checks by introducing calc-mode? and reusing calc? in render + effects.

Verification notes:

  • Static review only (no runtime UI/REPL validation executed in this environment). Change aligns with reported reproduction in logseq/db-test#990 (sidebar editor content staying stale while results update).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@megayu
megayu requested a review from tiensonqin July 8, 2026 14:40
@tiensonqin
tiensonqin force-pushed the fix/code-sidebar-sync branch from 69c0d37 to d4aad32 Compare July 15, 2026 14:09
@tiensonqin
tiensonqin force-pushed the fix/code-sidebar-sync branch from d4aad32 to 173695d Compare July 15, 2026 14:36
@tiensonqin
tiensonqin merged commit 2da66c2 into master Jul 15, 2026
10 checks passed
@tiensonqin
tiensonqin deleted the fix/code-sidebar-sync branch July 15, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar calc block fails to sync equation edits made in the main page (Only result updates)

3 participants