Skip to content

fix(Tooltip): keep the tooltip open when the pointer crosses onto it in one step - #7802

Merged
cixzhang merged 1 commit into
mainfrom
fix/tooltip-hover-bridge-one-step
Oct 21, 2026
Merged

cixzhang merged 1 commit into
mainfrom
fix/tooltip-hover-bridge-one-step

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

User impact

A mouse user who moves straight from a Tooltip's trigger onto the tooltip, in one pointer step across the small gap as a quick hand does, sees the tooltip disappear about a tenth of a second after the pointer lands on it. They cannot rest on it to read it or magnify it. A slow move that pauses in the gap keeps it open, so the failure depends on hand speed. Every Tooltip and useTooltip attachment shares this hover handling.

Problem and solution fit

  • Why it happens: useTooltip cancels its pending hide in the tooltip surface's React onMouseEnter. React derives that event from the browser's mouseout, which on a single pointer step fires before the trigger's native mouseleave. So the order is cancel, then schedule: the trigger's leave schedules the 100 ms hover-bridge hide after it was already cancelled, and it runs.
  • Why it harms: the tooltip closes under the pointer even though the pointer is on it.
  • Why that matters: WCAG requires hover content to stay while the pointer is over it, and the hook's hover bridge exists for exactly this case.

The trigger's leave now checks where the pointer went (relatedTarget). When that is inside the tooltip surface, it does not schedule a hide; the surface's own mouse leave schedules one when the pointer leaves the tooltip. Every other leave behaves as before.

Expected behavior and authority

  • spec:AST-020 FR1 (current): WCAG 2.2 Level A and AA are the conformance baseline. 1.4.13 Content on Hover or Focus (AA), Hoverable: "the pointer can be moved over the additional content without the additional content disappearing".
  • APG Tooltip pattern: the tooltip remains open while the cursor is over the trigger or the tooltip.
  • The hook already promises this: its hover bridge is documented as letting the pointer travel from the trigger onto the tooltip surface for WCAG 1.4.13.
  • The Tooltip accessibility contract in test(a11y): add Tooltip contract and bind Tooltip #7799 records this as a known failure in every Tooltip state (tooltip.hover.stays-while-hovered).

Smallest restoration

  • useTooltip's trigger mouseleave handler skips scheduleHide() when relatedTarget is inside the tooltip surface (looked up by the layer id in the pointer target's own document).
  • No prop, default, timing, or visual change. Focus, tap, controlled isOpen, and explicit hideDelay paths are untouched.

Evidence

  • Reproduction before the change: in Chromium, on the Tooltip Default story, hover the trigger until the tooltip shows, then move the mouse onto the tooltip in one step. The tooltip hides within ~100 ms (3/3 runs).
  • Result after the change: the same move leaves the tooltip open after 400 ms (3/3 runs).
  • Representative unchanged path: moving off the tooltip onto the page still hides it, before and after the change; the existing hover-bridge, hide-delay and touch tests pass unchanged.
  • Regression test or other mutation-sensitive proof:
    • TooltipHoverBridge.a11y.chromium.spec.ts (real Chromium, real mouse input) fails on main and passes here; it runs in the pr-a11y job.
    • A useTooltip.test.tsx case dispatches the browser's order (mouseout, then a raw mouseleave, both pointing at the tooltip) and fails on main.

Note for #7799: once this lands, that PR's known-failure records for tooltip.hover.stays-while-hovered become unexpected passes. Whichever of the two lands second should delete them.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run packages/core/src/Tooltip: 2 files, 47 tests pass; the new case fails without the fix.
  • Playwright Chromium against built Storybooks of this branch and of main's useTooltip: one-step crossing passes 3/3 here, fails 3/3 on main; leaving the tooltip hides it in both.
  • pnpm -F @astryxdesign/core typecheck, ESLint, Prettier, pnpm check:changesets: pass.

…in one step

React dispatches the surface's onMouseEnter from the mouseout that precedes
the trigger's native mouseleave, so on a one-step crossing the hide was
scheduled after it had been cancelled and the tooltip vanished about 100ms
after the pointer landed on it (WCAG 1.4.13 hoverable). The trigger's leave
now skips scheduling the hide when the pointer is moving onto the tooltip;
the tooltip's own mouse leave schedules it.
@astracat-bot

astracat-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 21, 2026, 4:43 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 21, 2026
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 21, 2026 4:25pm UTC

Request Review

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Tooltip (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 559 -
Complexity N/A Very High (62) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

40 of 486 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 20 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes are needed: a single pointer step from the trigger onto the tooltip now keeps it open, as WCAG 2.2 SC 1.4.13 requires, and both the new unit case and the Chromium spec cover it. The red test-node and smoke-test checks fail in CLI and CDN-template code this pull request does not touch, so they only need a re-run. One description fix: tooltips with an explicit hideDelay get the same fix, so "explicit hideDelay paths are untouched" understates the change.

[Automated review]

@cixzhang
cixzhang merged commit 7fbacfb into main Oct 21, 2026
88 of 92 checks passed
@cixzhang
cixzhang deleted the fix/tooltip-hover-bridge-one-step branch October 21, 2026 17:09
cixzhang added a commit that referenced this pull request Oct 21, 2026
…ger hosts

#7802 keeps the tooltip open when the pointer crosses onto it in one step,
so every Tooltip state now passes tooltip.hover.stays-while-hovered and the
known-failure ledger goes. Name the 24 hosts that pass focusTrigger
'always' and the suites that own their keyboard path, keep the content
assertion the removed duplicate test carried, and mark the advisory rows in
the README without reflowing its table.
cixzhang pushed a commit that referenced this pull request Oct 21, 2026
…#7530)

> Data items' `header` and `footer`, and the bottom sheet's level regions, follow once this merges.

## User need

A sub-menu picking from a long list needs a filter field above its rows, often a "Create" button below. #7344 gave the root menu `header` and `footer`; a sub-menu has neither, so the field goes among the rows (DEC-8 forbids it) or the picker leaves the menu.

## Problem and solution fit

`DropdownMenuSubMenu` takes `header` and `footer` under the root's rules (DEC-8, DEC-10). With either, the sub-menu's surface (the flyout, or the drilled-in view on a phone) is a modal dialog named by its row, holding the header, the sub-menu's `role="menu"` with rows only, and the footer. A flyout renders inside its parent menu, so `DropdownMenu` renders a host beside its menu for the dialog. A drilled-in view with regions replaces the root's menu and regions until popped, by a style rule that reads the host.

```tsx
<DropdownMenuSubMenu label="Labels" header={<TextInput label="Filter labels" … />} footer={<Button label="Create label" … />}>
  {visibleLabelRows}
</DropdownMenuSubMenu>
```

## Current specification

`component:DropdownMenu` (draft) gains a concept row, FR20, AR7 and DEC-13, all proposed and pending owner review. Other proposals in open pull requests: #7319 FR18/DEC-11, #7352 FR19/DEC-12, #7532 FR21/DEC-14, #7541 FR22/DEC-15. `module:DropdownMenu/useMenuPress` (current) gains a proposed ORD1a: a press released on a row of that dialog's menu acts, as FR1 requires for any flyout; a picker placed in its header or footer stays its own press root.

## Public delta and caller burden

- `header` and `footer` on `DropdownMenuSubMenu`.
- With either, the row says `aria-haspopup="dialog"`; Tab walks header, rows as one stop, footer, and wraps; an Escape nothing inside handled returns to the row; a pointer leaving the flyout keeps it open until focus leaves. Rendered beside the root's menu, such a flyout closes with the flyout holding its row.
- Phone drill-in: a shown view follows its regions and caps at the root's `menuMaxHeight`.
- `ContextMenu` renders no host: there the sub-menu shows its rows alone and warns in development; parity follows once this merges.
- Without them, nothing changes.

## Design and alternatives

Rejected: regions inside the flyout (inside the parent menu); a separate `DropdownMenu` per level; closing on pointer-leave, losing typed text. A drilled-in view's header sits above Back.

## Writing rubric results

- R1 narration: none.
- R2 research in a record: none.
- R3 evidence naming a change: none.
- R4 rejected alternatives over one line or outside a decision: none.
- R5 pull request or issue references: none.
- R6 ruled open questions listing options: none.

## Evidence

See Testing.

## Scope

- [x] One capability is added.
- [x] Unrelated fixes, cleanup, and policy changes were removed or split.
- [x] Consumer docs, focused tests, a story and a changeset ship with the feature.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

Review round 8 (rebased onto `main` b74cf21): `pr-a11y` gets a "Run DropdownMenu sub-menu header and footer contract" step beside "Run DropdownMenu header and footer contract". It runs `SubMenuHeaderFooter.a11y.chromium.spec.ts` with `--project chromium`, so FR20's real-engine checks gate every head. That exact command passes locally against a Storybook built from this head (6 cases). 15 files, +1867/−121 (1,988 lines). DropdownMenu, ContextMenu, Layer, MoreMenu, RadioList, `useMenuPress` and doc-prop suites: 739 tests; header and footer Chromium specs: 16; `.github/scripts` workflow tests: 100; typecheck, `lint:strict`, `check:knowledge`, Storybook build: clean.

Review round 7 (rebased onto `main` 863e167): `surfaceHost`, `surfaceOwnerId` and `menuMaxHeight` leave the exported `DropdownMenuContextValue` for `DropdownMenuSurfaceContext`, which the package does not export, layer-scoped and re-provided by each flyout as the menu context is; the public type matches `main`. A new `DropdownMenuContext.public.test.ts` pins its four members (it fails typecheck with the three back) and checks the internal context is not exported. Data-mode parity (data items' `header` and `footer`, `renderDropdownItems`, the bottom sheet's warning and their tests) moves to the follow-up, and the three pointer-leave cases share one setup: 14 files, +1856/−121 (1,977 lines). DropdownMenu, ContextMenu, Layer, MoreMenu, RadioList, `useMenuPress` and doc-prop suites: 739 tests; header and footer Chromium specs: 16; typecheck, `lint:strict` (no warnings), `check:knowledge`, Storybook build: clean.

Rebased onto `main` d0f9afe, no conflicts or changes. The previous head's `pr-a11y` and `smoke-test` reds came from CI: main's #7802 added a `pr-a11y` step whose spec file the older head lacked, and jsdelivr was still propagating [email protected]. DropdownMenu, ContextMenu, RadioList, docProp* suites: 477 tests; typecheck, `check:knowledge`: clean.

Review round 6: a flyout the pointer has left now decides that focus left once the move has completed, so an arrow key in a header radio group, where the browser moves focus itself, no longer closes it. A jsdom case replays the browser's order (focusout, a microtask checkpoint, focusin) and fails on the previous head; a Chromium case on the new "Submenu / header with a choice" story presses ArrowDown after the pointer leaves, and fails against a Storybook built from the previous head, where the flyout closes. DropdownMenu, ContextMenu, Layer, MoreMenu, RadioList, `useMenuPress` and doc-prop suites: 741 tests; header and footer Chromium specs: 16; typecheck, `lint:strict`, `check:knowledge`, Storybook build: clean.

Review round 5 (rebased onto `main` 2c3ed99; the earlier `test` and `test-node` reds were `main`'s own, a PostCSS fixture that #7797 fixed): an Escape a control in a region already handled (a header menu closing, a field clearing itself) closes nothing more, and the new case fails on the previous head. The contract takes FR20, AR7 and DEC-13 so open proposals in this record stay distinct. DropdownMenu, ContextMenu, Layer, MoreMenu, `useMenuPress` and doc-prop suites: 646 tests; header and footer Chromium specs: 15; typecheck, `lint:strict`, `check:knowledge`, Storybook build: clean.

Rebased onto `main` 577a62e after #7737 merged: one commit, 15 files, +1733/−109. DropdownMenu, ContextMenu, Layer, MoreMenu, `useMenuPress` and doc-prop suites: 645 tests; header and footer Chromium specs: 15; typecheck, `lint:strict`, `check:knowledge`, Storybook build: clean.

Review round 4 (amended into the last commit): the surface host is owned through a ref, with only a key in state that changes when a host attaches (it moves when the root's header or footer comes or goes); a drilled-in view with regions caps at the root's `menuMaxHeight`. New cases: the view cap (fails on the previous head) and the host move (a guard). Gates below are for this head.

Round 3, then stacked on #7737: the root steps aside for a view by a style rule over its surface host instead of a drill-in record kept in an Effect; a flyout with regions closes from the `onHide` of the flyout holding its row instead of an Effect; the bottom sheet's level regions moved to a follow-up. Each change has a case that fails with it reverted.

- `DropdownMenuSubMenu.test.tsx` "header and footer" suite: 20 cases, plus one in `ContextMenu.test.tsx` (rows alone, with the warning). They cover the dialog's role, modality, name and row wiring; regions outside every menu; the Tab walk and wrap from a field, a row and a deeper flyout; field keys; Escape, an IME Escape and Escapes a region handled; a press from a menu row released on a dialog row (acts) or its field (outside); a menu placed in a region keeping its own press; pointer-leave with focus inside, focus moving within (a header radio's arrow included), then focus leaving; a nested flyout closing with its parent; the phone drill-in, the root stepping aside, a shown view following its regions and its height cap.
- `__tests__/SubMenuHeaderFooter.a11y.chromium.spec.ts`, real Chromium: six cases (laptop structure, keyboard walk, picks, press-drag pick, a header radio after the pointer leaves; phone drill-in with the root stepped aside).
- iOS 26.2 simulator (Mobile Safari), earlier head: phone drill-in as described above; on `main` the level has no field or button.

This branch was successfully deployed

1 active deployment
Preview — cd24802b Deployed Oct 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant