fix(docs): heading anchor links now include the hash so it doesnt scoll all the way up, follows navbar logic#5791
Open
FucciUnavailable wants to merge 1 commit intocolinhacks:mainfrom
Conversation
…ll all the way up, follows navbar logic
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.
Fixes #5788
Problem
Clicking a heading (e.g. "Coercion") on a docs page like
/apisets theURL to
?id=coercion. Clicking the same heading a second time causes thepage to jump to the top instead of staying at the section.
This happens because the
<Link>only sets a query param (?id=coercion).When the URL hasn't changed, Next.js treats it as a no-op navigation —
no scroll happens, and the page snaps to top via scroll restoration.
The right-side TOC nav already uses
?id=coercion#coercion(both queryparam and hash), which works reliably on every click.
Fix
Add the hash to the heading anchor href to match what the TOC nav already does:
?id=${props.id}?id=${props.id}#${props.id}This means every click is always a real URL change (the hash is always
present), and the browser's native anchor scrolling handles positioning
correctly and idempotently.