Skip to content

fix(editor): keep preview heading sync stable#1075

Merged
perber merged 1 commit into
mainfrom
fix/editor-preview-heading-scroll-1061
May 30, 2026
Merged

fix(editor): keep preview heading sync stable#1075
perber merged 1 commit into
mainfrom
fix/editor-preview-heading-scroll-1061

Conversation

@perber
Copy link
Copy Markdown
Owner

@perber perber commented May 30, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 30, 2026 13:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Stabilizes editor-to-preview scroll synchronization when navigating headings in the Markdown editor preview, particularly for headings whose rendered structure can cause data-line targeting to be unreliable.

Changes:

  • Updates preview scroll targeting to prefer heading IDs (slug-based) and improves scroll position calculation/clamping.
  • Adds e2e coverage to ensure repeated heading clicks don’t reset preview scroll to the top.
  • Minor CSS formatting adjustment for a heading + code block selector.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
ui/leafwiki-ui/src/features/preview/markdownPreviewCodeTheme.css Reflows a complex selector for readability without changing behavior.
ui/leafwiki-ui/src/features/editor/MarkdownEditor.tsx Improves preview scrolling logic, adds heading-ID targeting, and keeps scroll position stable across preview re-renders/resizes.
e2e/tests/editor.spec.ts Adds an e2e regression test covering heading-click preview scroll stability (with a large fixture).

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

Comment thread ui/leafwiki-ui/src/features/editor/MarkdownEditor.tsx
Comment thread ui/leafwiki-ui/src/features/editor/MarkdownEditor.tsx
Comment thread e2e/tests/editor.spec.ts
@perber perber force-pushed the fix/editor-preview-heading-scroll-1061 branch from c77cf4f to 58314b5 Compare May 30, 2026 13:43
@perber perber requested a review from Copilot May 30, 2026 13:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread ui/leafwiki-ui/src/features/editor/MarkdownEditor.tsx
Keep smooth scrolling when selecting headings in the markdown editor while re-syncing after preview layout shifts.

Add an E2E regression test with a repo-owned markdown fixture that reproduces the preview jump-to-top behavior without relying on externally provided files.
@perber perber force-pushed the fix/editor-preview-heading-scroll-1061 branch from 58314b5 to 8761319 Compare May 30, 2026 15:11
@perber perber merged commit c449ded into main May 30, 2026
8 checks passed
@perber perber deleted the fix/editor-preview-heading-scroll-1061 branch May 30, 2026 15:22
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.

2 participants