Repository navigation
fix: Back in a multi-file annotate session keeps the reader's place - #2129
Merged
Merged
Conversation
A review of several files has no root document: each bundle file is a linked document, and Back from a document it links to reopens the bundle file through the file-browser path instead of calling useLinkedDoc's back(). The #2082 restore lives only in back() and only for the root, so the bundle file came back at its top. useLinkedDoc now remembers the reader's place in a linked document when it is left for another one, and open()/openLoaded() take restoreScroll to put them back with the same restore back() runs. Bundle Back passes it. Fixes #2128.
1 task
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 #2128.
In a review of several files (
plannotator annotate a.md b.md), following a link from the middle of a bundle file and pressing Back (the sidebar's "Back to review-alpha.md", or the header Back for an HTML page) brought the file back at its top. A single-file session keeps the place since #2084.Why: a bundle has no root document. Each bundle file is a linked document, and bundle Back reopens it through the file-browser path (
openBundleFile) instead of callinguseLinkedDoc'sback(). The #2084 restore lives only inback()and only for the root, so nothing remembered where the reader was in the bundle file, and the short linked document had already clamped the scroll to 0.Fix:
useLinkedDocremembers the reader's place in a linked document when it is left for another one (per path), andopen()/openLoaded()take an optionalrestoreScrollthat puts the reader back with the same restoreback()runs (re-anchors by block, stops on the reader's own input or a foreign scroll). Additive; noted inpackages/ui/HANDOFF.md.restoreScroll. The switcher and a link to another bundle file still open a file at its top, as before.Single-file sessions are unchanged. Folder sessions do not have this bug: their Back goes to the file list on purpose, not to the previous file.
Verified:
tests/e2e/annotate-bundle-back-scroll.spec.ts): released 0.28.29 goes from 9177 px to 0 after Back; this branch goes from 9177 px to 9177 px for both the linked markdown (sidebar Back) and the HTML page (header Back).packages/editor/App.bundleBackScroll.test.tsx, added to the CI DOM list): both Back paths land on the same block, and the switcher still opens at the top. Both Back tests fail without the fix.useLinkedDoc.scrollRestore.test.tsxforrestoreScroll, after a linked markdown and a linked HTML page, and that reopening without it leaves scrolling alone.bun run typecheck; all 199 editor/ui DOM test files in the CI list pass.