Skip to content

fix(desktop): stop tooltips re-opening when a menu/dialog restores focus to its trigger - #66737

Merged
OutThisLife merged 1 commit into
mainfrom
bb/tooltip-focus-open
Jul 18, 2026
Merged

fix(desktop): stop tooltips re-opening when a menu/dialog restores focus to its trigger#66737
OutThisLife merged 1 commit into
mainfrom
bb/tooltip-focus-open

Conversation

@OutThisLife

Copy link
Copy Markdown
Collaborator

Summary

Pick a model from the composer model pill and the pill's tooltip pops up (and stays) over your fresh selection — you didn't hover anything, it's just there. Same phantom tip on any Tip-wrapped trigger that opens an overlay.

Root cause: Radix Tooltip opens on any trigger focus, not just hover — its isPointerDownRef guard only suppresses the focus-open for a pointerdown on the trigger itself. Radix menus/dialogs restore focus to their trigger when they close, so every mouse-driven "open menu → click an item" round-trip ends with the trigger focused and the tooltip open. Nobody did it on purpose — it's the upstream default interacting with focus-restore.

Fix

TooltipTrigger gates the focus-open to keyboard focus: its own onFocus runs before Radix's composed handler and calls preventDefault() unless the trigger matches :focus-visible (composeEventHandlers skips Radix's onOpen for default-prevented events — verified against the installed @radix-ui/primitive). Chromium keeps focus-visible modality across the menu round-trip, so:

  • mouse pick → focus restore → no tooltip (fixed)
  • Tab to the button → tooltip still shows (a11y unchanged)
  • :focus-visible unsupported → fails open to the previous behavior

One central change in ui/tooltip.tsx; every Tip/TooltipTrigger call site inherits it.

Verification

  • New unit tests for the gate's three branches (suppress non-keyboard focus, keep keyboard focus, fail open on selector error)
  • npx vitest run src/components/ui/ src/app/chat/ src/app/shell/ — 167 tests green
  • tsc --noEmit, eslint, prettier — clean
  • Manual: open model pill with the mouse, pick a model → no phantom tip; Tab-focus the pill → tip shows

…cus to its trigger

Picking a model from the composer model pill left the pill's tooltip
stuck open over the fresh selection: Radix Tooltip opens on ANY trigger
focus (its isPointerDownRef guard only covers a pointerdown on the
trigger itself), and Radix menus/dialogs restore focus to their trigger
on close — so every mouse-driven pick ended with a phantom tip. Same
pattern on every Tip-wrapped trigger that opens an overlay.

Gate the focus-open to KEYBOARD focus: the trigger's own onFocus runs
before Radix's composed handler and calls preventDefault() unless the
trigger matches :focus-visible — composeEventHandlers skips onOpen for
defaultPrevented events. Chromium keeps focus-visible modality across
the menu round-trip, so a mouse pick's focus restore no longer opens
the tip, while Tab-focus still shows it (a11y unchanged). Fails open if
:focus-visible is unsupported.

Tests cover the three branches (suppress on non-keyboard focus, keep on
keyboard focus, fail open on selector error); chat/shell suites green.
@OutThisLife
OutThisLife enabled auto-merge July 18, 2026 05:06
@OutThisLife
OutThisLife merged commit 65f1c94 into main Jul 18, 2026
23 checks passed
@OutThisLife
OutThisLife deleted the bb/tooltip-focus-open branch July 18, 2026 05:09
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/desktop Electron desktop app (apps/desktop/*) labels Jul 18, 2026
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…cus-open

fix(desktop): stop tooltips re-opening when a menu/dialog restores focus to its trigger
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
…cus-open

fix(desktop): stop tooltips re-opening when a menu/dialog restores focus to its trigger
prmartinow pushed a commit to prmartinow/hermes-agent that referenced this pull request Aug 26, 2026
…cus-open

fix(desktop): stop tooltips re-opening when a menu/dialog restores focus to its trigger
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
…cus-open

fix(desktop): stop tooltips re-opening when a menu/dialog restores focus to its trigger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants