Skip to content

Commit 5a876e1

Browse files
fix(website): re-clamp hovered bubbles on close and resize
Two Greptile P2s, both valid states the first clamp pass missed: - Tapping a tooltip closed it while the pointer stayed over it; :hover keeps the bubble visible but the close path cleared the shift, so an edge bubble jumped outside the viewport until re-hover. Re-clamp instead of clearing when :hover still matches. - The resize re-clamp matched only [open] bubbles; hover-only ones kept a stale shift across viewport changes. Match :hover too.
1 parent 88a44ac commit 5a876e1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎website/site/src/components/InfoTip.astro‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,19 @@ const id = `tip-${Astro.props['detail'] ? '' : ''}${Math.random().toString(36).s
152152
// The bubble lays out on the same frame the attribute flips; measure
153153
// after layout so getBoundingClientRect sees the real rect.
154154
requestAnimationFrame(() => clamp(d))
155+
} else if (d.matches(':hover')) {
156+
// Tap-close while the pointer stays over the tooltip: :hover keeps
157+
// the bubble visible, so re-clamp instead of clearing the shift.
158+
clamp(d)
155159
} else {
156160
const bubble = d.querySelector<HTMLElement>('.tip-bubble')
157161
if (bubble) bubble.style.transform = ''
158162
}
159163
})
160164
})
161-
// Re-clamp when the viewport moves under an open bubble (rotation, resize).
165+
// Re-clamp when the viewport moves under a visible bubble (rotation,
166+
// resize) — hover-opened bubbles have no [open], so match both.
162167
window.addEventListener('resize', () => {
163-
document.querySelectorAll('details.info-tip[open]').forEach(clamp)
168+
document.querySelectorAll('details.info-tip[open], details.info-tip:hover').forEach(clamp)
164169
}, { passive: true })
165170
</script>

0 commit comments

Comments
 (0)