Skip to content

fix(ui-source-code-editor): Scroll bug in SourceCodeEditor#2493

Merged
git-nandor merged 1 commit intomasterfrom
INSTUI-4948_Scroll_bug_in_SourceCodeEditor
Apr 7, 2026
Merged

fix(ui-source-code-editor): Scroll bug in SourceCodeEditor#2493
git-nandor merged 1 commit intomasterfrom
INSTUI-4948_Scroll_bug_in_SourceCodeEditor

Conversation

@git-nandor
Copy link
Copy Markdown
Contributor

@git-nandor git-nandor commented Mar 27, 2026

INSTUI-4948

Summary

Preserve scroll position in controlled mode.

When SourceCodeEditor is in controlled mode (value prop), refreshEditorValue()
replaces the entire document which triggers CodeMirror's view update cycle.
This causes the scroll position to reset to the top even though the cursor
position is correctly restored.

Fix

Saving the scroll position before the content update and restoring
it after CodeMirror has updated the DOM using requestAnimationFrame.

Test plan

  1. Open the SourceCodeEditor docs page.
  2. In the first example, inspect the <div data-cid="SourceCodeEditor" ...> element and
    set its height from auto to 80px.
  3. Scroll to the /** This is an example section inside the editor.
  4. Start typing and verify the behavior.

Co-Authored-By: 🤖 Claude

@git-nandor git-nandor self-assigned this Mar 27, 2026
@git-nandor git-nandor marked this pull request as ready for review March 27, 2026 16:15
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 27, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-04-07 09:13 UTC

Copy link
Copy Markdown
Contributor

@joyenjoyer joyenjoyer left a comment

Choose a reason for hiding this comment

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

looks good

@git-nandor git-nandor merged commit 49dd754 into master Apr 7, 2026
11 of 12 checks passed
@git-nandor git-nandor deleted the INSTUI-4948_Scroll_bug_in_SourceCodeEditor branch April 7, 2026 09:13
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.

3 participants