From c4aa2eddce8d2d713fb6ca16196fd7d5410c5c39 Mon Sep 17 00:00:00 2001 From: troyejames9 <130838331+TroyeJames9@users.noreply.github.com> Date: Fri, 15 Aug 2025 13:31:47 +0800 Subject: [PATCH] fix(popover): reset preview scroll position for same-page section links Signed-off-by: troyejames9 <130838331+TroyeJames9@users.noreply.github.com> --- quartz/components/scripts/popover.inline.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quartz/components/scripts/popover.inline.ts b/quartz/components/scripts/popover.inline.ts index 989af7ee8..004198b4b 100644 --- a/quartz/components/scripts/popover.inline.ts +++ b/quartz/components/scripts/popover.inline.ts @@ -29,6 +29,10 @@ async function mouseEnterHandler( popoverElement.classList.add("active-popover") setPosition(popoverElement as HTMLElement) + // ensures always operate on the live DOM element rather than a closed-over variable reference + const popoverInner = popoverElement.querySelector(".popover-inner") as HTMLElement | null + if (!popoverInner) return + if (hash !== "") { const targetAnchor = `#popover-internal-${hash.slice(1)}` const heading = popoverInner.querySelector(targetAnchor) as HTMLElement | null