fix(popover): reset preview scroll position for same-page section links

Signed-off-by: troyejames9 <130838331+TroyeJames9@users.noreply.github.com>
This commit is contained in:
troyejames9 2025-08-15 13:31:47 +08:00
parent e77a051144
commit c4aa2eddce

View File

@ -29,6 +29,10 @@ async function mouseEnterHandler(
popoverElement.classList.add("active-popover") popoverElement.classList.add("active-popover")
setPosition(popoverElement as HTMLElement) 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 !== "") { if (hash !== "") {
const targetAnchor = `#popover-internal-${hash.slice(1)}` const targetAnchor = `#popover-internal-${hash.slice(1)}`
const heading = popoverInner.querySelector(targetAnchor) as HTMLElement | null const heading = popoverInner.querySelector(targetAnchor) as HTMLElement | null