Repository navigation
fix(desktop): scroll the view up when the caret moves above the viewport (#3329) - #4742
Merged
Merged
Conversation
…ort (#3329) The `selection-change` scroll handler only auto-scrolled when the caret neared the bottom edge (#628), so moving the caret up (Arrow-Up) let it slide above the viewport without the document following. Add the symmetric upward scroll when the caret rises within 100px of the top edge. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3329
Problem
Moving the caret down scrolls the document so the caret stays visible, but moving it up (Arrow-Up) did not — the caret slid above the viewport while the text stayed put.
Root cause
The
selection-changehandler ineditorWithTabs/editor.vueonly handled the bottom edge (the #628 fix): when the caret is within 100px of the bottom (container.clientHeight - y < 100) it scrolls down. There was no symmetric branch for the top edge, so arrow keys (handled by the engine, which sets the caret programmatically and does not trigger the browser's native scroll-into-view) never scrolled the container upward.Reproduced in the real built app (e2e): with a tall document, moving the caret to the bottom scrolls the view down, but moving it back up leaves
scrollTopunchanged — the caret leaves the viewport.Fix
Add the symmetric upward scroll: when the caret rises within 100px of the top edge (
y < 100), scroll the container up so it stays visible — mirroring the existing down-scroll. It's anelse if, so the two edges never fight, and it clamps toscrollTop: 0at the document top.Tests
Added
test/e2e/scroll-up-arrow.spec.ts(real Electron app): in a 120-paragraph doc, pressing Arrow-Down scrolls the view down (already worked), and pressing Arrow-Up brings it back up. Confirmed RED on the pre-fix build (the up case leaves the view at the bottom) → GREEN after the fix, deterministic across 3 repeats. ESLint +vue-tsctypecheck pass.