fix(website): keep the heading fragment on a hard-loaded docs deep link - #1079
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
blove
enabled auto-merge (squash)
September 9, 2026 02:09
Contributor
blove
force-pushed
the
blove/clever-sammet-6ce520
branch
from
September 9, 2026 02:18
bd88006 to
e0e4a99
Compare
Contributor
blove
force-pushed
the
blove/clever-sammet-6ce520
branch
from
September 9, 2026 02:41
e0e4a99 to
8fce0cf
Compare
Contributor
Hard-loading `/docs/<library>/<section>/<slug>#heading` landed at the top of the article instead of the heading. Not a dev-server artifact: measured against a production build, the heading sat ~9760px below the reading pane. The article is server-rendered straight into the document, so the browser performs its native scroll to the fragment on the page scroller. Hydration then mounts `WebsiteWorkspaceSurface`, `html:has([data-website-workspace-host])` starts matching `overflow: hidden`, the page scroller ceases to exist, and the real scroller — `.docs-workspace-article`, mounted with the shell — starts at zero. No script resets anything; CSS simply discards the scroll, and nothing puts the reader back. Shared links, search results and the heading-granular deep links the docs search emits are all exactly this shape, and the failure is silent: the page renders perfectly, just in the wrong place. Re-apply the fragment once, on the mount that takes the scrolling over. The resulting position is identical to clicking the same rail link, including the shell's pre-existing 45px section offset. Non-workspace docs pages were never affected — they keep the document scroller and `html`'s `scroll-padding-top`. The one report against `/docs/choosing-an-adapter` was a cold `next dev` compile dropping the pending fragment scroll, which a production build does not do; the new spec covers that page anyway so the difference stays recorded. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
blove
force-pushed
the
blove/clever-sammet-6ce520
branch
from
September 9, 2026 03:02
8fce0cf to
4317ba5
Compare
Contributor
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.
The bug
Hard-loading
/docs/<library>/<section>/<slug>#headinglands at the top of the article instead of at the heading. This is not a dev-server artifact — measured against a production build (nx build website+nx serve --configuration=production),/docs/langgraph/guides/streaming#whats-nextleft the heading 9760px below the reading pane, with.docs-workspace-articleatscrollTop: 0.Shared links, search-engine results, and the heading-granular deep links the docs search emits are all exactly this shape, and the failure is silent: the page renders perfectly, just in the wrong place.
Root cause
Traced with instrumented hooks on
scrollTo/scrollIntoView/scrollTop/focus:scrollYclimbs 2 → 25useLayoutEffectregisters the workspace andWebsiteWorkspaceSurfacemountshtml:has([data-website-workspace-host])starts matchingoverflow: hidden(apps/website/src/styles/docs.css) — the page scroller ceases to exist and the scroll clamps to 0.docs-workspace-article, mounted with the shell, becomes the only scroller and starts at 0. Nothing re-applies the fragment.No script resets anything — CSS discards the scroll. That is why none of the scroll-mutation hooks fired.
Non-workspace docs pages (
/docs/choosing-an-adapter) were never affected: they keep the document scroller andhtml'sscroll-padding-top.The fix
One
useEffect(…, [])inWebsiteWorkspaceSurface— at the exact mount that causes the loss — re-applyinglocation.hashwithscrollIntoView({ block: 'start' }). The resulting position is byte-identical to clicking the same rail link, including the shell's pre-existing 45px section offset.Coverage
apps/website/e2e/docs-deep-link.spec.ts, one test per page kind. Two deliberate details:about:blankbetween gotos.page.goto()to a URL differing only by#hashis a same-document navigation and never reloads — the first draft of this spec passed against the broken build because of it.Mutation-tested: with the fix removed the workspace test fails (9760), with it restored it passes.
About the original report
The symptom was first seen on
/docs/choosing-an-adapter#ag-ui-adapterundernx serve website. That page is fine — on a route's firstnext devrequest Turbopack compiles it,loadfires early, and Chrome drops the pending fragment scroll (zero scroll events, ever). Warm dev and production both land it at nav-bottom + 16px, exactly thescroll-padding-top. The spec covers that page too, so the distinction stays recorded rather than being re-investigated.Verification
--repeat-each=3.docs.spec.ts+docs-shell.spec.ts+ the new spec: 33 passed, twice.workspace shell › …without replacing the runtime frame, which needs a live cockpit runtime on:4300. A/B'd with the fix on and off in the same environment: identical failure both ways, so it is environmental (a concurrent local session held that port).nx build websiteclean,nx lint website0 errors,nx test websitegreen.🤖 Generated with Claude Code