Skip to content

fix: close tooltips when their anchors become inert - #299

Merged
starc007 merged 2 commits into
starc007:mainfrom
l4u532:fix/tooltip-inert-trigger
Nov 30, 2026
Merged

starc007 merged 2 commits into
starc007:mainfrom
l4u532:fix/tooltip-inert-trigger

Conversation

@l4u532

@l4u532 l4u532 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

tl;dr

  • A toolbar tooltip can stay painted over Morphing Lightbox after the viewer makes the toolbar inert.
  • Tooltip blocks new opens from inert anchors and closes open labels when their anchors become inert.

Reproduction and cause

Hover a toolbar button, then open Morphing Lightbox by timer or keyboard shortcut. Keep the pointer still. The viewer marks the toolbar's ancestor inert. Chrome sent a pointerleave, and Tooltip's pointer corridor kept the label open while it waited for another pointer move. A delayed hover could also open after the ancestor became inert.

Tooltip now checks for [inert] at the hover request and again when the label would open. While open is requested, it watches the anchor and its ancestors. A delayed hover rechecks the anchor when its timer fires. For an open tooltip, an inert anchor cancels close and pointer-corridor work and requests a close through the existing tooltip lifecycle. On a trigger that Tooltip manages, it also removes the description link.

Scope and contract

The check covers TooltipTrigger, shorthand triggers, and external HTML or SVG anchors. Controlled open={true} stays visually suppressed while inert. A caller that keeps open={true} can show the label again when the anchor becomes active.

Morphing Lightbox sets an explicit inert attribute. Drawer, Bottom Sheet, Morphing Modal, and Center Morph Modal use focus traps and leave the background trigger outside the attribute's scope. Native showModal() uses browser-managed inertness and is outside this change. Chrome hit-tested the native dialog above the tooltip, which stayed in the document.

Browser verification

Captured on 2026-11-29 against c0944430 and d58d8935. The Chrome GIF and frame sheet show the label disappearing when the toolbar becomes inert. The Lightbox pairs show where the baseline label lingered.

Chrome toolbar

Chrome toolbar Before and after GIF

Chrome toolbar Chrome comparison frames
Chrome Lightbox

Chrome Lightbox before

Chrome Lightbox after
iPad Safari Lightbox

iPad Safari Lightbox before

iPad Safari Lightbox after

Check Chrome Safari
Morphing Lightbox Passed. The resting pointer sent one leave in both versions. The baseline label persisted. The fixed label was gone by the first sampled inert frame in the final run. Passed on iPad touch. The label was visible in 37/37 sampled inert frames before and 1/34 after.
Direct inert ancestor Passed. The label closed and the trigger lost its tooltip description. Passed on iPad touch. Visible in 37/37 inert samples before and 0/36 after.
Delayed and initially inert opens Passed. The baseline delayed hover opened while inert. The fix blocked it and removed the initial description link from an inert trigger. Unverified. iPad runs used touch, and desktop Safari was unavailable for interactive checks on the locked display.
Controlled state, focus-out and external HTML or SVG anchors Passed. Controlled focus-out requested one close. External anchors closed, including an HTML anchor reattached under an inert parent. Unverified. The iPad run covered the trigger-owned touch path.
Focus-trap overlays Passed for scope. All four overlays left the background trigger outside [inert] in both revisions. Passed for scope on iPad. The same four overlays left the background trigger outside [inert].
Native showModal() Passed for scope. Hit-testing at the label returned the native dialog in both revisions. Unverified. The iPad run covered the beUI overlays.
Keyboard focus, Escape, pointer corridor and reduced motion at 375 px Passed. Tab focus added the description, Escape closed the tooltip, and the corridor held the label open. All 39 reduced-motion samples per revision fit within the viewport and had no transform. Unverified. The locked desktop prevented interactive checks, and the iPad run used touch at its default viewport and motion setting.

The browser checks ran after the dev route mounted interactively. Its site chrome logged a hydration mismatch, so first paint is unverified.

Test plan

  1. Hover a Tooltip button. Add inert to its containing toolbar while the pointer stays still. The label closes and aria-describedby clears.
  2. Repeat before the hover delay expires. The label stays closed while the toolbar is inert.
  3. For the Lightbox case, render a Tooltip button beside a controlled Morphing Lightbox (value and onValueChange). Give a separate button a click handler that opens the first image after one second. Press it, then hover the Tooltip button and hold still. The label disappears when the viewer opens.
  4. Run bun run check and bun test. Both commands passed, including 196 registry components and 240 accessibility tests. The new test checks tooltip exposure and its description link after the trigger becomes inert.

@l4u532

l4u532 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Updated in a8068145.

  • About copy. The accessibility paragraph now names the element Tooltip watches: its anchor, which is the trigger, or the anchorRef element when one is passed. With both a trigger and an anchorRef, Tooltip positions on and observes the anchorRef element. No component in the repository combines the two.
  • Description. The lifecycle sentence now says what happens before and after open. A delayed hover rechecks the anchor when its timer fires. An open tooltip cancels close and corridor work when its anchor becomes inert. The Lightbox test step now sets up the delayed open from scratch, with a controlled Morphing Lightbox.

There is no runtime change. bun run check (196 registry components) and bun test (240 tests) pass.

@starc007

Copy link
Copy Markdown
Owner

thanks! #303 just merged and this now conflicts in lib/component-about.ts (tooltip accessibility paragraph) and lib/component-dates.ts. can you rebase on main? keep both changes in the tooltip paragraph.

@l4u532
l4u532 force-pushed the fix/tooltip-inert-trigger branch from a806814 to fe8f560 Compare November 30, 2026 09:10
@l4u532

l4u532 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Updated: rebased on main at ad6d11c (#303). The head is now fe8f560.

Verification on 2026-11-30:

  • bun run check passed with 196 registry components. bun test passed 240 tests.
  • I ran a temporary happy-dom check on the merged code. It is not part of the PR. A tooltip was shown on a button outside an open Dropdown Menu, then outside an open Table Menu. In both cases, one press on that button closed the menu. An inert ancestor removed the tooltip and its description link. After the attribute was removed, an outside press still closed the menu. All three cases failed on a tree without fix: let overlays handle presses and Tab on tooltip anchors #303 and this PR.
  • I did not rerun the browser checks in the description. This PR's Tooltip code is unchanged by the rebase.

@starc007
starc007 merged commit 8798f3f into starc007:main Nov 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants