Repository navigation
fix: keep restored scroll - #97
Merged
Merged
Conversation
The client restores the scroll of a page in the swap, but it intercepted each navigation with the default scroll behavior, "after-transition". The browser then scrolled again once the navigation settled, so going back to a list scrolled half way showed the right place, then jumped to the top. The client now intercepts with scroll: 'manual'.
lukeed
force-pushed
the
fix/manual-scroll
branch
from
November 3, 2026 02:39
30cc6a9 to
e94fd3f
Compare
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.
Summary
Going back to a page that was scrolled, such as a list scrolled half way, showed the page at the right place, then jumped to the top.
The client restores the scroll of each page itself, in the swap. But it intercepted each navigation with the default scroll behavior of the Navigation API,
"after-transition", so the browser scrolled again once the navigation settled. A trace ofhistory.back()on a page restored toy=4962: the client scrolls there at 68 ms, the page is aty=0atnavigatesuccess, and a later scroll puts it back. Depending on timing, the page can stay at the top.scroll: 'manual', so only its own restore runs: the saved place on back and forward, the hash target or the top on push and replace.This touches the same
event.intercept()call as #92, so whichever merges second needs a small rebase.Performance
Client runtime, minified and gzipped: 3,371 B → 3,376 B.
Test plan
scroll: 'manual'bongo dev: back to a list scrolled toy=6694stays at 6694 throughnavigatesuccess(onmain, it is at 0 there); a link from the list still lands at the top of the new pagebun run build,bun test,bunx tsc -p .,bunx tsc -p build