fix(ui): in-page anchor navigation for headings#605
Open
dgrissen2 wants to merge 1 commit intobacknotprop:mainfrom
Open
fix(ui): in-page anchor navigation for headings#605dgrissen2 wants to merge 1 commit intobacknotprop:mainfrom
dgrissen2 wants to merge 1 commit intobacknotprop:mainfrom
Conversation
Intercept `#`-prefixed link clicks and smooth-scroll inside the sticky scroll viewport instead of letting the browser jump (which broke when the content lives inside a scrollable container). Headings now expose both a canonical slug and a legacy slug via `data-anchor-aliases` so older shared URLs keep resolving. Also listen for `hashchange` / initial hash so direct links land on the right heading. Adds `packages/ui/utils/anchors.ts` with `normalizeAnchorText`, `decodeAnchorHash`, `slugifyHeadingAnchor`, `legacySlugifyHeadingAnchor`, and `getHeadingAnchorAliases` (+ tests). Also ignore `.serena/` tooling state.
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
#-prefixed link clicks inInlineMarkdownand smooth-scrollwithin the sticky scroll viewport. The native browser jump didn't work
because plan content lives inside a scrollable container, not the
document root.
data-anchor-aliasesso previously shared URLs keep resolving. Canonicalcollapses runs of separators; legacy preserves them.
hashchangeand the initial hash so direct links land on theright heading after load.
packages/ui/utils/anchors.tswithnormalizeAnchorText,decodeAnchorHash,slugifyHeadingAnchor,legacySlugifyHeadingAnchor,getHeadingAnchorAliases+ unit tests.onNavigateAnchorthroughBlockRenderer,AlertBlock,Callout,TableBlock,TablePopout,proseBody..serena/tooling state.Test plan
bun test packages/ui/utils/anchors.test.ts## Part I: Overview: Scopeand click a TOC linklike
[Scope](#part-i-overview-scope)— scrolls smoothly, stickyheader isn't overlapping the target.
(
#part-i--overview--scope) — still resolves via alias.#some-headingin the URL directly — auto-scrollson first render.
navigate in-page.