Files
gitbook/packages
Zeno Kapitein be0d5d25f0 Re-assert scroll to anchor so cross-page links land on target (RND-11844)
A cross-page anchor link navigated to the right page but stayed at the top.
GitBook's `scrollToHash` scrolled once, but a soft navigation delivers the
destination asynchronously — content keeps mounting and reflowing for a few
hundred ms after the URL changes — so the single scroll landed before the
target reached its final position, and #4089 routed cross-section navigations
through it. It also scrolled to the top on a transiently-empty hash context.

- scrollToHash re-scrolls to the target on each DOM change until the DOM goes
  quiet, mirroring the fragment scrolling the browser does for free during a
  full page load. It bails if the visitor scrolls, so we never fight them.
- useScrollPage decides the hash from the context value for same-page anchors
  (authoritative, set on click) and from `window.location.hash` for cross-page
  navigations (where the context hash is transiently empty during the remount).

Next keeps handling the baseline scroll (top on plain/query navigations, the
top fallback for missing anchors); GitBook only re-asserts the hash scroll it
would otherwise land too early on.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-14 19:36:10 +02:00
..
2026-02-25 11:37:48 +01:00
2025-10-15 13:30:24 +02:00
2026-07-06 12:52:44 +00:00
2026-05-19 13:24:41 +02:00
2026-07-06 12:52:44 +00:00