From 181ffd1e5c1d0b5cef9f694cf76fa4dac181675c Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sun, 26 Apr 2026 09:59:12 +0200 Subject: [PATCH] feat(navigation): smooth scroll for in-note anchor links Pure-fragment links (#heading) used to fall through to the browser's default jump. Handle them in the click listener and scope the lookup to the same stacked note so identical heading ids in other notes don't win, with smooth scroll behavior to match cross-note anchors into already-stacked notes. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/hooks/useLinks.hook.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/hooks/useLinks.hook.ts b/src/hooks/useLinks.hook.ts index f5a6b3d..f099965 100644 --- a/src/hooks/useLinks.hook.ts +++ b/src/hooks/useLinks.hook.ts @@ -19,6 +19,15 @@ export const useLinks = ( } if (href.startsWith("#")) { + event.preventDefault() + const id = href.slice(1) + const container = document.querySelector(`.${toValue(className)}`) + const heading = container?.querySelector(`#${CSS.escape(id)}`) + heading?.scrollIntoView({ + block: "start", + inline: "nearest", + behavior: "smooth" + }) return }