fix(popover): inconsistent behavior due to id mismatch

This commit is contained in:
Emile Bangma 2025-04-10 20:07:47 +00:00 committed by GitHub
parent 9db66d500e
commit 8deea58ca8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -91,7 +91,7 @@ async function mouseEnterHandler(
normalizeRelativeURLs(html, targetUrl)
// prepend all IDs inside popovers to prevent duplicates
html.querySelectorAll("[id]").forEach((el) => {
const targetID = `popover-internal-${el.id}`
const targetID = `popover-${el.id}`
el.id = targetID
})
const elts = [...html.getElementsByClassName("popover-hint")]
@ -106,7 +106,7 @@ async function mouseEnterHandler(
document.body.appendChild(popoverElement)
if (hash !== "") {
const targetAnchor = `#popover-internal-${hash.slice(1)}`
const targetAnchor = `#popover-${hash.slice(1)}`
const heading = popoverInner.querySelector(targetAnchor) as HTMLElement | null
if (heading) {
// leave ~12px of buffer when scrolling to a heading