Skip to content

fix: Back in a multi-file annotate session keeps the reader's place - #2129

Merged
backnotprop merged 2 commits into
mainfrom
fix/bundle-back-scroll
Oct 24, 2026
Merged

backnotprop merged 2 commits into
mainfrom
fix/bundle-back-scroll

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

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 calling useLinkedDoc's back(). The #2084 restore lives only in back() 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:

  • useLinkedDoc remembers the reader's place in a linked document when it is left for another one (per path), and open() / openLoaded() take an optional restoreScroll that puts the reader back with the same restore back() runs (re-anchors by block, stops on the reader's own input or a foreign scroll). Additive; noted in packages/ui/HANDOFF.md.
  • Bundle Back passes 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:

  • Playwright on the compiled binary with the issue's fixture at 1440×1000 (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).
  • DOM test of the whole editor (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.
  • Hook tests in useLinkedDoc.scrollRestore.test.tsx for restoreScroll, 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.

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.
@backnotprop
backnotprop merged commit 01ca9b0 into main Oct 24, 2026
29 of 30 checks passed
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.

[Bug] Multi-file Annotate Back returns to the top instead of restoring scroll position (#2082 follow-up)

1 participant