fix(docs): stop mobile /docs from jumping to top on scroll#9
Merged
Conversation
The IntersectionObserver-driven pill auto-centering effect called scrollIntoView on a pill anchor inside a position:sticky header. On mobile browsers, scrollIntoView walks the scroll-ancestor chain and (with sticky positioning) can scroll the document scroller even with block:'nearest', producing a smooth-scroll animation that fights the user's own scroll and yanks the page toward the top on every section change. Scroll the pill <ul> container directly instead, so only the horizontal pill bar moves and the document scroll is never touched.
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
/docsbug where the page constantly snapped toward the top on scroll, tap, or section navigation.DocsLayoutran anIntersectionObserver-driven effect that calledscrollIntoView({ behavior: 'smooth', inline: 'center', block: 'nearest' })on a pill anchor inside theposition: stickyheader. On mobile browsers,scrollIntoViewwalks the scroll-ancestor chain and — with sticky positioning — can scroll the document even withblock: 'nearest', kicking off a smooth animation that fights the user's own scroll on every section change.<ul>container directly viacontainer.scrollTo({ left, behavior: 'smooth' }), so only the horizontal pill bar moves and the document scroller is never touched.Test plan
/docsand scroll through sections — verify the page no longer jumps toward the top as the active pill changes./docs(≥ lg breakpoint, sidebar visible) — verify nothing regresses; the sidebar highlight should still follow the active section.npm run build(typecheck + Vite build) passes locally.