Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

fix(tooltip): dismiss lingering tooltips on pointerdown and Escape (#826) (#832)

suantea (asuan_suan)90e6984fc2b1
diff --git a/client/src/components/tooltip.tsx b/client/src/components/tooltip.tsx
index 0c6f4fcc..959956b6 100644
--- a/client/src/components/tooltip.tsx
+++ b/client/src/components/tooltip.tsx
@@ -24,12 +24,18 @@ export function Tooltip({ text, children, side = 'top', className }: {
}
const hide = () => setCoords(null)
- // #826: a modal (copy-key / model-scope dialog) opening on top of the
- // trigger swallows the mouseleave, so the tooltip state survives the dialog
- // and the black box lingers after it closes. While visible, also hide on any
- // mousemove that leaves the trigger's rect (with a small tolerance to avoid
- // flicker at the edge) — the pointer-events-none tooltip itself never
- // intercepts events, so this is the reliable cleanup.
+ // #826: a hover tooltip lingers after a dialog (copy full key / model
+ // scope) is opened on top of its trigger and closed again — the mouse never
+ // actually leaves the trigger, so `mouseleave` never fires and the tooltip
+ // stays until the pointer happens to cross another hot-zone. Two
+ // complementary cleanups, both only attached while a tooltip is showing:
+ // - hide on any mousemove that leaves the trigger's rect (with a small
+ // tolerance to avoid flicker at the edge) — the pointer-events-none
+ // tooltip itself never intercepts events, so this is the reliable
+ // cleanup when the pointer actually moves away;
+ // - hide on any pointerdown (covers the click that opens the dialog) and
+ // on Escape (the dialog's own close key), so a tooltip can't outlive the
+ // popup that covered it even if the pointer never moves.
useEffect(() => {
if (!coords) return
const onMove = (e: MouseEvent) => {
@@ -40,8 +46,18 @@ export function Tooltip({ text, children, side = 'top', className }: {
&& e.clientY >= r.top - 4 && e.clientY <= r.bottom + 4
if (!inside) hide()
}
+ const onPointerDown = () => hide()
+ const onKeyDown = (e: KeyboardEvent) => {
+ if (e.key === 'Escape') hide()
+ }
document.addEventListener('mousemove', onMove)
- return () => document.removeEventListener('mousemove', onMove)
+ document.addEventListener('pointerdown', onPointerDown)
+ document.addEventListener('keydown', onKeyDown)
+ return () => {
+ document.removeEventListener('mousemove', onMove)
+ document.removeEventListener('pointerdown', onPointerDown)
+ document.removeEventListener('keydown', onKeyDown)
+ }
}, [coords])
return (