fix(popover): cache no longer always misses

This commit is contained in:
saberzero1 committed 2026-04-16 16:38:16 +02:00
1 parent b9d4298321
commit 5bec6fb87b
2 files changed
+193 -5

No files matched your search

+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" })
}
}
}
}