Skip to content

fix(docs): stop mobile /docs from jumping to top on scroll#9

Merged
TheAlexPG merged 1 commit intomainfrom
fix/docs-mobile-scroll-jump
Apr 25, 2026
Merged

fix(docs): stop mobile /docs from jumping to top on scroll#9
TheAlexPG merged 1 commit intomainfrom
fix/docs-mobile-scroll-jump

Conversation

@TheAlexPG
Copy link
Copy Markdown
Owner

Summary

  • Fixes the mobile /docs bug where the page constantly snapped toward the top on scroll, tap, or section navigation.
  • Root cause: DocsLayout ran an IntersectionObserver-driven effect that called scrollIntoView({ behavior: 'smooth', inline: 'center', block: 'nearest' }) on a pill anchor inside the position: sticky header. On mobile browsers, scrollIntoView walks the scroll-ancestor chain and — with sticky positioning — can scroll the document even with block: 'nearest', kicking off a smooth animation that fights the user's own scroll on every section change.
  • Fix: scroll the pill <ul> container directly via container.scrollTo({ left, behavior: 'smooth' }), so only the horizontal pill bar moves and the document scroller is never touched.

Test plan

  • On a phone (or DevTools mobile emulation), open /docs and scroll through sections — verify the page no longer jumps toward the top as the active pill changes.
  • Tap a pill — verify the page anchors to the section as expected, with no follow-up jump.
  • Verify the active pill still auto-centers in the horizontal pill bar as you scroll.
  • Desktop /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.

Do not merge — PR is open for review only.

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.
@TheAlexPG TheAlexPG merged commit 7e96205 into main Apr 25, 2026
3 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.

1 participant