fix(popover): cache no longer always misses

This commit is contained in:
saberzero1
2026-04-16 16:38:16 +02:00
parent b9d4298321
commit 5bec6fb87b
2 changed files with 193 additions and 5 deletions
+8 -5
View File
@@ -30,11 +30,14 @@ async function mouseEnterHandler(
setPosition(popoverElement as HTMLElement)
if (hash !== "") {
const targetAnchor = `#popover-internal-${hash.slice(1)}`
const heading = popoverInner.querySelector(targetAnchor) as HTMLElement | null
if (heading) {
// leave ~12px of buffer when scrolling to a heading
popoverInner.scroll({ top: heading.offsetTop - 12, behavior: "instant" })
const inner = popoverElement.querySelector(".popover-inner") as HTMLElement | null
if (inner) {
const targetAnchor = `#popover-internal-${hash.slice(1)}`
const heading = inner.querySelector(targetAnchor) as HTMLElement | null
if (heading) {
// leave ~12px of buffer when scrolling to a heading
inner.scroll({ top: heading.offsetTop - 12, behavior: "instant" })
}
}
}
}