Repository navigation
fix(ui): open neighbouring tooltips without the full delay - #58971
Conversation
There was a problem hiding this comment.
The fix is sound and minimal. On the base, a tooltip next to one that was showing waited the full delay; with this change it opens immediately.
I tested it in a Bun + happy-dom harness, because neither checkout had a browser binary. The harness compiles the real Tooltip and Kobalte code with babel-preset-solid and renders three adjacent tooltips with openDelay={2000}. I hovered one, then moved across its neighbours with 250ms on each:
- Base: the open / skipped / open pattern from the description.
- This PR: every neighbour opened at once. Leaving still closes the tooltip, and hovering again still waits the full delay.
Kobalte 0.13.13's trigger confirms the cause: hideTooltip(), which starts the skip-delay window, only runs if the tooltip is still open when Kobalte's own pointerleave handler runs. Otherwise it calls cancelOpening(). I haven't checked the desktop app or a real browser.
packages/ui tests pass (153 passed, 0 failed), and tsc --noEmit is clean.
Public API is unchanged; this is internal to the UI Tooltip component.
Related: #50811
Problem
Hovering across the review toolbar's segmented controls (Show all lines / Hide non-diff lines / Unified diff / Split diff) shows tooltips inconsistently. When you move from a tooltip that's showing to the button next to it, the second tooltip often waits the full open delay (2s on these buttons) and doesn't appear unless you keep hovering.
Cause
Tooltippasses its ownonPointerLeaveto Kobalte's trigger, and that handler closes the tooltip directly. Kobalte runs the passed handler before its own, so Kobalte sees the tooltip as already closed. It then callscancelOpening()instead ofhideTooltip(), which means theskipDelayDurationwindow that lets the next tooltip open immediately never starts.Fix
Defer the wrapper's close/unblock to a microtask, so Kobalte's leave handler still sees the tooltip open and starts the skip-delay window. The tooltip still closes on leave, and the click/expanded-content blocking stays the same.
Verification
I used a scratch Vite page (not committed) with the same two segmented controls and
openDelay={2000}, driven by headless Chromium. Hover one button for 2.2s, then move across neighbours with 250ms on each:In both cases, leaving the controls closes the tooltip, and hovering again after that still waits the full delay (nothing shows at 600ms, it shows at 2.4s).
bun run typecheckinpackages/uipasses.packages/uihas no DOM tests for tooltips. Not yet checked in the desktop app.Test update
session-question-dock.spec.tshovers Submit and then Back. Back's tooltip now opens right away, while Submit's is still in its 80ms fade-out, so a baregetByRole("tooltip")matches two elements. The assertion now targets Back's tooltip by name.Requested by: @vimtor (victor via Slack)