Repository navigation
fix: keep the reading position when opening a long draft - #5100
Merged
Merged
Conversation
Place the reading and its editor in the same grid cell while the editor connects. Removing the reading then leaves the editor where it stood, so native scroll anchoring does not follow it upward. Max-content rows keep a pane draft overflowing its viewport rather than stretching its reading to it. Closes #5083
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.
Opening a long Markdown draft could reset the document to the top: the editor initially stood below the reading, then native scroll anchoring followed it upward when its ready state hid the reading. The reading and editor now occupy one grid cell throughout that handoff, so clicking a visible word keeps the reading position and transfers its caret. Content-sized rows preserve scrolling inside a bounded pane.
The regression starts at #4872: the existing document test passes on its parent and fails at that commit with the reported 429px reset. That change intentionally joined Markdown soft breaks; this repair keeps that behavior and corrects the layout handoff instead. The existing document and pane cases, wrapped-draft geometry, and draft Return tests pass (5 tests); all 745 runtime tests and the changed files’ pre-commit checks pass.
Visual evidence
The same journey writes a long draft, saves it, scrolls to Line 30 and clicks that word. Before, the document jumps back to the draft’s head; after, Line 30 stays at the clicked height. The existing short-editor, hover and phone states are pixel-identical between base and head.
Verification and scope
uv run pytest 'tests/browser/drafts/test_draft_editing.py::test_opening_a_visible_line_in_a_long_draft_preserves_the_reading_position[document-markdown]' -q -n0fails on base and passes with the correction. The unchanged test checks scroll offsets, the draft’s position, the clicked source caret and the exact editor value.uv run pytest tests/browser/drafts/test_draft_editing.py -k 'opening_a_visible_line or wrapped_draft or document_edit_enter' -q -n0— 5 passed.uv run leaf-dev stills 32501ddf2 --state release-draft --state release-draft-long --state release-draft-hover --state release-draft-phone.release-notes: document delivery, upgrade and first server-state presentation add no requests or JavaScript bytes (45 requests and 2,326,152 JavaScript bytes before presentation in both arms). Total bytes rise from 3,024,878 to 3,025,175; code bytes rise by 222 for the CSS. Both arms show the same pre-upgrade layout-shift diagnostic. Single-run elapsed times are not a performance conclusion.Closes #5083 — automated triage