Skip to content

fix(Tooltip): keep Escape-dismissed tooltip closed while pointer rests on trigger (#11895) - #13003

Open
ravindrasinghshah wants to merge 5 commits into
meta:mainfrom
ravindrasinghshah:fix/tooltip-escape-dismissal-11895
Open

ravindrasinghshah wants to merge 5 commits into
meta:mainfrom
ravindrasinghshah:fix/tooltip-escape-dismissal-11895

Conversation

@ravindrasinghshah

@ravindrasinghshah ravindrasinghshah commented Nov 19, 2026 •

Copy link
Copy Markdown

Primary intent

Bug fix. Restore the Escape-dismissed Tooltip staying closed while the pointer rests on its trigger (#11895).

User or maintainer impact

Anyone who dismisses a tooltip with Escape while the pointer rests on its trigger — the tooltip reopens on its own, with no new pointer movement. After the fix, the dismissal holds until the pointer leaves and re-enters, or focus leaves and comes back.

Authority

Change

  • A dismissedByEscapeRef is armed in useLayerDismissal onDismiss only while a new isPointerOverRef says the pointer is over the trigger or the tooltip surface; it is cleared in handleMouseLeave, in the surface's onMouseLeave, in handleFocusOut once focus has actually left, and where a disabled detach settles in settleDetach.
  • handleMouseEnter returns early while the flag is set. The trigger's mouseenter and the surface's onMouseEnter set isPointerOverRef; leaving either for anywhere but the other clears it.
  • No change to show(), the touch path, or handleFocusIn, and no new API, visual, or default.

Evidence

  • Before: new test "stays closed on a fresh mouseenter while the pointer never left after Escape" failed — onShow was called 2 times instead of 1.
  • After: all 118 tests pass across useTooltip.test.tsx, useTooltip.showHide.test.tsx, and Tooltip.test.tsx.
  • Representative unchanged path: pointer resting on the button centre — a normal hover after leave and re-enter still shows the tooltip, and focus leave and return re-enables it.
  • Regression tests: five new tests in useTooltip.test.tsx — three inside describe("useTooltip — Escape dismissal") (the mouseenter case above, "shows again after focus leaves and returns following an Escape dismissal", and "shows on hover after a keyboard-focus Escape"), and two in describe("useTooltip — a trigger that detaches and attaches again") ("shows on hover after an Escape that follows a detached-while-hovered reattach" and "shows on hover after an Escape and a detached-while-hovered menu pick").

Scope

Components: Tooltip

  • This PR has one primary intent.
  • Independently removable API, visual, layout, behavior, cleanup, and policy changes were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run packages/core/src/Tooltip/useTooltip.test.tsx packages/core/src/Tooltip/useTooltip.showHide.test.tsx packages/core/src/Tooltip/Tooltip.test.tsx — 118 passed.
  • @astryxdesign/core typecheck — clean, 0 errors.
  • ESLint and Prettier — clean on the changed files.
  • jsdom tests only; no real-browser run, since the behavior under test is event ordering, not layout or pixels.

@vercel

vercel Bot commented Nov 19, 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 Nov 20, 2026 3:02am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔄 In progress (for maintainers only) Nov 20, 2026, 2:44 AM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 19, 2026
@meta-cla

meta-cla Bot commented Nov 19, 2026

Copy link
Copy Markdown

Hi @ravindrasinghshah!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@ravindrasinghshah ravindrasinghshah changed the title fix(Tooltip): keep Escape-dismissed tooltip closed while pointer rest… fix(Tooltip): keep Escape-dismissed tooltip closed while pointer rests on trigger (#11895) Nov 19, 2026
@meta-cla

meta-cla Bot commented Nov 19, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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.

Thanks for the fix: it keeps an Escape-dismissed tooltip closed while the pointer rests on its trigger, and the new test fails on main and passes here. One change is needed before this can be approved:

  • useTooltip.tsx:977 sets the dismissal flag on every Escape, so when the pointer is not over the trigger or the tooltip at that moment (a tooltip opened by keyboard focus, or one shown by isDefaultOpen), the first time the mouse enters the trigger afterwards nothing shows, although the Tooltip contract (FR3) opens on entering the trigger; set the flag only while the pointer is over the trigger or the tooltip, and add a test for a keyboard-focus Escape followed by a hover.

Two optional comment rewrites are in the inline notes.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Changeset, an Escape-dismissed tooltip stays closed while the pointer rests on its trigger: verified for that state (the new test fails on the base and passes here); the change also reaches dismissals made with the pointer elsewhere (finding above).
  • The flag is set when Escape dismisses and cleared on pointer leave and on focus leaving the trigger: verified (useTooltip.tsx:977, :556, :641).
  • A pointer enter returns early while the flag is set: verified (useTooltip.tsx:547).
  • No change to show(), the touch path, showing on focus, the API, visuals or defaults: verified (the diff, and an API report with no rows).
  • The new mouseenter test failed before the fix with two show calls: verified on the base.
  • All 115 tests in the three Tooltip suites pass: verified.
  • A hover after leaving and entering again shows, and focus leaving and returning shows: verified by the new tests.
  • The second new test guards the focus path: verified; it also passes on the base.
  • Core typecheck, ESLint and Prettier are clean: verified.
  • The linked issue's expected behavior and the maintainer's confirmation are described accurately: verified.
  • .changeset/tooltip-escape-dismissal-stays-closed.md: clear.
  • packages/core/src/Tooltip/useTooltip.tsx: one blocking finding, two comment suggestions.
  • packages/core/src/Tooltip/useTooltip.test.tsx: clear; no test covers an Escape made with the pointer elsewhere.

Automated review (maintainer link)

@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.

Thanks for the update: arming the Escape flag only while the pointer is over the trigger or the tooltip fixes the keyboard-focus and isDefaultOpen cases, and the issue's resting-pointer case stays fixed (the new test fails on main and passes here). Two changes are needed before this can be approved:

  • isPointerOverRef and dismissedByEscapeRef are cleared only by mouseleave and focus leaving, so when a caller removes the trigger's wiring while it is hovered (DropdownMenu does this to its Button while the menu is open) a pointer that leaves is never seen, and after an Escape the next real hover onto the trigger shows nothing although FR3 opens the tooltip on entering it; clear both refs where a disabled detach settles in settleDetach and add a test for hover, detach, leave, reattach, Escape and hover.
  • The description says two new tests and 115 passing tests, but the head adds three tests and the three suites run 116, and its Change list leaves out isPointerOverRef and the tooltip surface's new mouse handlers, so please update the Change, Evidence and Testing lines.

CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Claims and files checked

Review mode: full; reason: author-not-engowner

  • Claim: an Escape-dismissed tooltip stays closed while the pointer rests on its trigger — verified (the new test fails on main and passes here; a Chromium run on the issue's trigger).
  • Claim: the dismissal holds until the pointer leaves and re-enters, or focus leaves and returns — verified for that state by the new tests.
  • Claim: the issue's expected behaviour, the maintainer's confirmation and the Tooltip contract's Escape rule are cited correctly — verified.
  • Claim: the flag is set in the dismissal callback, cleared on pointer leave and on focus leaving, and checked in the hover handler — verified (useTooltip.tsx:984, :562, :648, :553); the list leaves out the pointer tracking and the surface handlers.
  • Claim: no change to show(), the touch path or focus showing, and no new API, visual or default — verified (no API rows; the open-state frames are identical).
  • Claim: before the fix the new test called onShow twice — verified.
  • Claim: two new regression tests and 115 passing tests — false (three new tests; 116 pass).
  • Claim: typecheck, ESLint and Prettier are clean — verified.
  • Claim (release note): the tooltip stays dismissed with Escape while the pointer rests on its trigger — verified.
  • File .changeset/tooltip-escape-dismissal-stays-closed.md — clear.
  • File packages/core/src/Tooltip/useTooltip.tsx — blocking finding (pointer state survives a detach).
  • File packages/core/src/Tooltip/useTooltip.test.tsx — clear; no test covers a detach while hovered.

Automated review (maintainer link)

@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.

Thanks for the update: resetting the pointer state when a disabled trigger detaches fixes both DropdownMenu hover paths, and the issue's resting-pointer case stays fixed (the new test fails on main and passes here, and in Chromium the tooltip stays closed after Escape where main reopens it). One change is needed before this can be approved:

  • The description still says the change adds two new tests and that 115 tests pass, but the head adds five tests (three under Escape dismissal and two in the detach suite) and the three suites run 118, and its Change list leaves out isPointerOverRef, the tooltip surface's new mouse handlers and the reset in settleDetach, so please update the Change, Evidence, Regression test and Testing lines.

The code itself needs no change; one optional comment-wording suggestion is inline. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Claims and files checked

Review mode: full; reason: author-not-engowner

  • Claim: an Escape-dismissed tooltip stays closed while the pointer rests on its trigger — verified (the new test fails on main and passes here; a Chromium run on the issue's trigger).
  • Claim: the dismissal holds until the pointer leaves and re-enters, or focus leaves and returns — verified by the new tests.
  • Claim: the issue's expected behaviour, the maintainer's confirmation and the Tooltip contract's Escape rule are cited correctly — verified.
  • Claim: the flag is set in the dismissal callback, cleared on pointer leave and on focus leaving, and checked in the hover handler — verified (useTooltip.tsx:988, :562, :648, :553); the list leaves out the pointer tracking, the surface handlers and the detach reset.
  • Claim: no change to show(), the touch path or focus showing, and no new API, visual or default — verified (no API rows; the hovered frames are identical).
  • Claim: before the fix the new test called onShow twice — verified.
  • Claim: hover after leave and re-enter, and focus leaving and returning, still show the tooltip — verified by the new tests.
  • Claim: two new regression tests and 115 passing tests — false (five new tests; 118 pass).
  • Claim: typecheck, ESLint and Prettier are clean — verified.
  • Claim (release note): the tooltip stays dismissed with Escape while the pointer rests on its trigger — verified.
  • File .changeset/tooltip-escape-dismissal-stays-closed.md — clear.
  • File packages/core/src/Tooltip/useTooltip.tsx — clear; one non-blocking comment-wording suggestion.
  • File packages/core/src/Tooltip/useTooltip.test.tsx — clear.

Automated review (maintainer link)

Comment on lines +348 to +350
// An Escape dismissal sets this flag. Closing the surface can give the
// trigger a mouseenter with no pointer movement. While the flag is set, that
// enter shows nothing. A pointer leave or a focus leave clears the flag.

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.

Non-blocking: the first and last sentences narrate where the flag is set and cleared, and they no longer match the code: an Escape with the pointer elsewhere leaves it unset (line 988), and a surface leave or a disabled detach also clears it. Keeping only the reason:

// Closing the surface can give the trigger a mouseenter with no pointer
// movement. While this is set, that enter shows nothing.

This branch was successfully deployed

1 active deployment
Preview — 58c24768 Deployed Nov 20, 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. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant