Skip to content

fix(preview): make footnote & heading anchor links navigate (#69) - #89

Merged
adibhanna merged 1 commit into
mainfrom
fix/footnote-anchor-links
Jun 10, 2026
Merged

fix(preview): make footnote & heading anchor links navigate (#69)#89
adibhanna merged 1 commit into
mainfrom
fix/footnote-anchor-links

Conversation

@adibhanna

Copy link
Copy Markdown
Contributor

Fixes #69 — footnotes did nothing in the (split) preview, and should link both ways.

Cause

Footnote refs/back-refs render as in-page anchors (#…fn-1#…fnref-1). The preview's click handler ended in a catch-all e.preventDefault() that swallowed those clicks — and the browser's native hash navigation doesn't scroll a target that lives inside the preview's own overflow:auto container anyway. (The sanitizer keeps the href/id, so the markup was fine — purely a navigation gap.)

Fix

When a clicked anchor's href is a #-fragment, resolve the target by id within the preview container and scrollIntoView it, with a brief accent highlight so the jump is visible. Works both ways — ref → definition and the back-ref → reference — and also fixes heading/TOC anchor links.

Verification

  • Reproduced + fixed against the demo tour note 06 — Callouts and Footnotes in Split/Preview (clicking a footnote jumps to its definition and back).
  • npm run typecheck passes.

One-spot change in Preview.tsx; independent of #88 (different region of the same file).

Footnote refs/back-refs render as in-page anchors (`#…fn-1` ⇄ `#…fnref-1`),
but the preview's click handler ended in a catch-all preventDefault that
swallowed them — and native hash navigation doesn't scroll a target inside
the preview's own overflow:auto container anyway, so footnotes did nothing
in preview/split.

Resolve `#`-fragment anchors against the preview container and scroll the
target into view, with a brief accent highlight. Works both ways (ref →
definition and the ↩ back-ref → reference) and also fixes heading/TOC
anchor links.

Fixes #69
@adibhanna adibhanna mentioned this pull request Jun 10, 2026
@adibhanna
adibhanna merged commit 38c3487 into main Jun 10, 2026
5 checks passed
@adibhanna
adibhanna deleted the fix/footnote-anchor-links branch June 10, 2026 14:02
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.

footnotes

1 participant