Repository navigation
Conversation
…thout showing
With isOpen={false}, hover reported nothing and focus opened the
tooltip and reported onOpenChange(true), so a caller could not hold it
closed. Now a hover that would open it after the delay, or focus that
would open it, calls onOpenChange(true) once and shows nothing, matching
how a held-open tooltip reports Escape as onOpenChange(false) without
hiding. component:Tooltip FR7 records the symmetric contract, drops its
implementation gap and the matching current-state entry, and gains a
verification row.
…p-controlled-intent # Conflicts: # docs/specs/components/Tooltip/Tooltip.spec.md
…e-wired one closes (red)
With held-closed hover reporting onOpenChange(true), a tooltip wired to state opened on hover but never heard the leave, so it stayed open. A held-open tooltip now reports a pointer or focus leave as onOpenChange(false) and hides nothing, as it does for Escape. FR7, the hook and component docs and the changeset say so, and the record drops the gap references this change removes (eight gaps remain).
…in a patch
A held-closed tooltip reports keyboard focus as onOpenChange(true) and
shows nothing. The held-open leave report and the held-closed hover
report change released behavior, so they move to a separate change for
the next minor. FR7 keeps 'isOpen={true} suppresses hover and focus
hiding' and adds only the focus report.
…p-controlled-intent
…overs Held open, a pointer or focus leave that would hide the tooltip calls onOpenChange(false) and hides nothing; held closed, a hover that would open it after delay calls onOpenChange(true) once. A tooltip wired to state now opens on hover and closes on leave, as Lab's copy-link tooltip in CommentActions expects. This changes released controlled behavior, so the changeset is [breaking] with a migration, for the next minor.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Outcome: this needs an engineering owner's decision before approval. The pull request rewrites component:Tooltip FR7 so that a controlled tooltip reports hover (onOpenChange(true) while held closed) and pointer or focus leave (onOpenChange(false) while held open), replacing the current "isOpen={true} suppresses hover and focus hiding". An engineering owner records that decision by commenting /approve-spec followed by the full head commit SHA; the author may do so as an engineering owner.
Blocking, still needed after that decision:
- Desktop behavior change needs an owner decision: a mouse hover now opens and a mouse leave now closes a state-wired tooltip, including Lab's copy-link tooltip (the show and hide timers in
useTooltip.tsx), so either gate it to touch input or cite the owner decision that covers it in the description. - The changeset says a controlled tooltip "reports every open and close request" and "behaves like an uncontrolled one", but pressing the trigger still leaves a state-wired tip open with no report, so reword it to "reports hover, focus and leave requests … pressing its trigger still leaves it open".
Tooltip.doc.mjsdescribes only Escape for a held-open tip, so add that a pointer or focus leave that would hide it also callsonOpenChange(false), the part of this change that breaks apps pinning a tip.
Worth adding: a held-open focus-leave test (the behavior works but nothing pins it) and one line on why no codemod applies.
[Automated review]
| '@astryxdesign/core': minor | ||
| --- | ||
|
|
||
| [breaking] A controlled `Tooltip` now reports every open and close request, so a tooltip wired to state (`isOpen={open} onOpenChange={setOpen}`) behaves like an uncontrolled one. Held open (`isOpen={true}`), a pointer or focus leave that would hide it calls `onOpenChange(false)` and hides nothing, the same call Escape makes. Held closed (`isOpen={false}`), a hover that would open it after `delay` calls `onOpenChange(true)` once and shows nothing. `useTooltip` reports the same requests through `onShow` and `onHide`. |
There was a problem hiding this comment.
Pressing the trigger closes an uncontrolled tooltip but leaves a state-wired one open with no onOpenChange call (useTooltip.tsx:681-683, and FR7 still says a controlled tooltip "is not closed by pressing the trigger"), so "reports every open and close request" and "behaves like an uncontrolled one" overstate the change. Suggested wording: "A controlled Tooltip now reports hover, focus and leave requests, so a tooltip wired to state opens on hover and closes when the pointer or focus leaves, like an uncontrolled one; pressing its trigger still leaves it open."
| type: 'boolean', | ||
| description: | ||
| 'Controlled open state for the tooltip. Held closed, focus that would open it calls onOpenChange(true) and shows nothing; held open, Escape calls onOpenChange(false) and it stays.', | ||
| 'Controlled open state for the tooltip. Held closed, a hover or focus that would open it calls onOpenChange(true) once and shows nothing; held open, Escape calls onOpenChange(false) and it stays.', |
There was a problem hiding this comment.
This leaves out the held-open leave report, which is the part that breaks apps pinning a tip; useTooltip.doc.mjs already says it. Suggested: "…held open, Escape or a pointer or focus leave that would hide it calls onOpenChange(false) and it stays."
| const latest = latestRef.current; | ||
| if (latest.isOpen === false) { | ||
| latest.onShow?.(); | ||
| return; |
There was a problem hiding this comment.
This timer (and the hide timer at 515-518) changes what a mouse does for a state-wired tooltip: hover now opens it and leave now closes it, with no pointer-type gate. That desktop behavior change needs an owner decision cited in the description, or a touch-only gate.
| // Held closed, the hover reports through onShow and shows nothing. The | ||
| // caller decides. |
There was a problem hiding this comment.
Non-blocking: the first sentence restates the branch below (and the same at 506-507). Keeping only the reason reads: "The caller owns a controlled isOpen, so a held tooltip reports instead of acting."
| | FR2–FR8 | `Tooltip.test.tsx`; `useTooltip.test.tsx` | Hover, focus, tap, Escape, controlled, default open; `auto` judged when focus arrives (roving member, `<summary>`, non-focusable wrapper) | Wrong open or close for an input fails. | `audit:Tooltip/behavior` | | ||
| | FR4, FR7 reattach | `useTooltip.test.tsx` detach-and-attach suite; `DropdownMenuTooltip.a11y.chromium.spec.ts` | A trigger that detaches while open; keyboard and pointer focus that arrive while detached; a data menu, a compound menu and a bottom sheet: a pointer pick, a keyboard pick, and Escape | A tooltip left open after its trigger detaches, a tooltip after a pointer pick, or none for returned keyboard focus, fails. | `audit:Tooltip/behavior` | | ||
| | FR7 held closed | `Tooltip.test.tsx` controlled suite; `useTooltip.test.tsx` controlled suite | With `isOpen={false}`, keyboard focus; with `isOpen={true}`, Escape and a pointer leave | A held-closed tooltip that shows on focus, or reports focus other than one `onOpenChange(true)`, fails; Escape on a held-open tooltip that hides it, or a pointer leave that hides it, fails. | `audit:Tooltip/behavior` | | ||
| | FR7 held closed | `Tooltip.test.tsx` controlled suite; `useTooltip.test.tsx` controlled suite | With `isOpen={false}`, hover and keyboard focus; with `isOpen={true}`, Escape and a pointer leave; a state-wired tooltip (`isOpen={open} onOpenChange={setOpen}`) | A held-closed tooltip that shows, or reports hover or focus intent other than one `onOpenChange(true)`, fails; Escape or a pointer leave on a held-open tooltip that hides it, or reports nothing, fails; a state-wired tooltip that stays shown after the pointer leaves fails. | `audit:Tooltip/behavior` | |
There was a problem hiding this comment.
Non-blocking: FR7 above states that a held-open focus leave reports onOpenChange(false) too, and it does, but this row and the tests cover only Escape and a pointer leave. A held-open focus-leave case in the Tooltip.test.tsx controlled suite, named here, would pin it.
…p-intent-minor # Conflicts: # docs/specs/components/Tooltip/Tooltip.spec.md # packages/core/src/Tooltip/Tooltip.doc.mjs # packages/core/src/Tooltip/Tooltip.test.tsx # packages/core/src/Tooltip/Tooltip.tsx # packages/core/src/Tooltip/useTooltip.doc.mjs # packages/core/src/Tooltip/useTooltip.tsx
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
There was a problem hiding this comment.
Outcome: approval waits on an engineering owner's decision. This pull request rewrites component:Tooltip FR7 so that a controlled tooltip reports hover (onOpenChange(true) while held closed) and pointer or focus leave (onOpenChange(false) while held open), replacing the current "isOpen={true} suppresses hover and focus hiding". An engineering owner records that decision by commenting /approve-spec followed by the full head commit SHA on this pull request; the author may do so as an engineering owner.
Blocking, still needed after that decision:
- Desktop behavior change needs an owner decision: a mouse hover now opens and a mouse leave now closes a state-wired tooltip, including Lab's copy-link tooltip (the show and hide timers in
useTooltip.tsx), so either gate it to touch input or cite the decision that covers it in the description. - The changeset says a controlled tooltip "reports every open and close request" and "behaves like an uncontrolled one", but pressing the trigger still leaves a state-wired tip open with no report, so reword it to say it reports hover, focus and leave requests and that pressing the trigger still leaves it open.
Tooltip.doc.mjsdescribes only Escape for a held-open tip, so add that a pointer or focus leave that would hide it also callsonOpenChange(false), the part of this change that breaks apps pinning a tip.- Miss: the Tooltip record's Compatibility and migration section still calls the component's compatibility additive with "Migration decision: none", so state the FR7 transition and its migration there and in the Contract at a glance compatibility row.
Worth adding: a held-open focus-leave test (the behavior works but nothing pins it), an update to the record's untested-claims line for FR7, and one sentence on why no codemod applies.
[Automated review]
| | FR5 | On touch and pen, a completed tap opens the tooltip per `touchTrigger` when the finger lifts; a touch that becomes a scroll, or a press the browser does not count as a tap, does not open it. Under `auto`, a tap opens it unless the trigger itself performs an action; an `aria-disabled` control, or a label for a disabled control, is not an action, so a disabled control's reason opens on a tap, even inside a clickable row or card (DEC-1). Under `tap`, every tap opens it; under `none`, no tap does. A second tap on the trigger, a tap outside, or a scroll starting outside closes it. On a button that pins through `show()`, the button's click decides what a tap does (FR9). Whether `auto` also leaves the tooltip shut when the tap acts on a control around the trigger is open (OQ1). | Current source and tests | | ||
| | FR6 | Escape closes a visible tooltip; Escape during text composition is ignored. Escape routing follows `family:overlay-dismissal`: a visible topmost tooltip in the page handles that Escape, so a layer underneath stays open for that press. Implementation gap: a tooltip rendered into another document, such as an iframe or a Picture-in-Picture window, with no layer beneath it is never closed by Escape (Current-state impact). `spec:AST-003` FR4, accepted and not yet implemented, makes an unpinned tooltip passive and gives a pinned one Escape first (Current-state impact). Outside a `show()` hold (FR12), pressing an uncontrolled tooltip's trigger closes it; a press that focuses a text-entry trigger reopens it through FR4. | WCAG 1.4.13; tests | | ||
| | FR7 | `isOpen` forces the tooltip shown or hidden, and `isOpen={true}` suppresses hover and focus hiding; a controlled tooltip answers Escape by calling `onOpenChange(false)` without hiding, and is not closed by pressing the trigger. With `isOpen={false}`, focus FR4 opens on calls `onOpenChange(true)` and shows nothing. `isDefaultOpen` opens it on mount, still dismissible. `isEnabled={false}` disables triggers and drops a pending open. A trigger whose caller removes it while disabling the tooltip closes its open, uncontrolled tooltip; when it attaches again enabled, the tooltip shows only for focus FR4 would open on. A trigger that detaches and attaches again while the tooltip stays enabled keeps the tooltip as it is. | Current source and tests | | ||
| | FR7 | `isOpen` forces the tooltip shown or hidden. A controlled tooltip answers Escape, and with `isOpen={true}` a pointer leave or focus leave that would hide it, by calling `onOpenChange(false)` without hiding, and is not closed by pressing the trigger. Symmetrically, a controlled tooltip reports hover or focus intent by calling `onOpenChange(true)` without showing: with `isOpen={false}`, a hover that would open it after `delay`, or focus FR4 opens on, calls `onOpenChange(true)` once and shows nothing. `isDefaultOpen` opens it on mount, still dismissible. `isEnabled={false}` disables triggers and drops a pending open. A trigger whose caller removes it while disabling the tooltip closes its open, uncontrolled tooltip; when it attaches again enabled, the tooltip shows only for focus FR4 would open on. A trigger that detaches and attaches again while the tooltip stays enabled keeps the tooltip as it is. | Current source and tests | |
There was a problem hiding this comment.
Miss: this FR7 now changes released controlled behavior, but the record's Compatibility and migration section still says "Compatibility class: additive … no public prop, default, DOM, or target change" (:69), states no controlled-behavior transition (:73-77) and keeps "Migration decision: none" (:84); the Contract at a glance compatibility row (:51) names only the additive show/hide. Please state the FR7 transition and its migration there. The untested-claims list at :276 also still reads "FR7: isOpen={true} suppressing focus hiding", which this FR7 no longer states.
- Tooltip.test: the React import takes main's names plus useState. - Comments.test: main's two failed-copy tests and this branch's copy-link tooltip close test are all kept.
There was a problem hiding this comment.
Outcome: approval waits on an engineering owner's decision. This pull request rewrites component:Tooltip FR7 so that a controlled tooltip reports hover (onOpenChange(true) while held closed) and pointer or focus leave (onOpenChange(false) while held open), replacing the current "isOpen={true} suppresses hover and focus hiding". An engineering owner records that decision by commenting /approve-spec followed by the full head commit SHA on this pull request; the author may do so as an engineering owner.
Blocking, still needed after that decision:
- Regression: with keyboard focus on a Button whose label is cut short (or a Table header whose heading is cut), a mouse passing over it and away now closes the full-label tooltip while focus stays, because the new leave report reaches the internal
UndescribedTooltip, whoseonHidecloses it, so keep that tooltip open through a pointer leave and add a test where the mouse crosses the focused Button. - Miss: lint in strict mode, as CI runs it, fails with two
@eslint-react/exhaustive-depserrors atuseTooltip.tsxlines 498 and 518, so addlatestRefto thescheduleShowandscheduleHidedependency arrays. - Desktop behavior change needs an owner decision: a mouse hover now opens and a mouse leave now closes a state-wired tooltip, including Lab's copy-link tooltip (the show and hide timers in
useTooltip.tsx), so either gate it to touch input or cite the decision that covers it in the description. - The changeset says a controlled tooltip "reports every open and close request" and "behaves like an uncontrolled one", but pressing the trigger still leaves a state-wired tip open with no report, so reword it to say it reports hover, focus and leave requests and that pressing the trigger still leaves it open.
Tooltip.doc.mjsdescribes only Escape for a held-open tip, so add that a pointer or focus leave that would hide it also callsonOpenChange(false), the part of this change that breaks apps pinning a tip.- Miss: the Tooltip record's Compatibility and migration section still calls the component's compatibility additive with "Migration decision: none", so state the FR7 transition and its migration there and in the Contract at a glance compatibility row.
Worth adding: a held-open focus-leave test (the behavior works but nothing pins it), an update to the record's untested-claims line for FR7, and one sentence on why no codemod applies.
Claims and files checked
Review mode: full; reason: recipe-changed (many rules)
- Changeset: a controlled tooltip reports every open and close request — false: a press on a controlled trigger reports nothing (
useTooltip.tsx:678-680). - Changeset: a state-wired tooltip behaves like an uncontrolled one — false for a press on the trigger (same lines).
- Changeset: held open, a pointer or focus leave asks to close and hides nothing — verified (
useTooltip.tsx:510-515,Tooltip.test.tsx:446, a focus-leave check). - Changeset: held closed, a hover asks to open once after the delay and shows nothing — verified (
useTooltip.tsx:485-495,Tooltip.test.tsx:364). - Changeset: the hook reports the same through
onShowandonHide— verified (useTooltip.test.tsx:534,:545). - Changeset: before, held-open hiding was suppressed silently and a held-closed hover reported nothing — verified: the new tests fail on the base.
- Changeset: apps that agree to every call lose a pinned tip on leave and reopen an Escape-closed tip on hover — verified (pinned-tooltip story in Chromium; code path).
- Changeset: the migration steps — consistent with the code.
- Description: builds on the merged held-closed focus report — verified (on
main). - Description: today a state-wired tooltip never opens on hover and a held-open one ignores leaves — verified on the base.
- Description: Lab's copy-link tooltip never opens on hover on
mainand now opens, then closes on leave — verified (Comments.test.tsxcase fails on the base; Chromium); its quotedisOpenexpression now also includes the failed-copy flag. - Description: a pointer leaving before the delay drops the hover report — verified (
useTooltip.test.tsx:555). - Description: Tooltip maps both reports to
onOpenChange— verified (Tooltip.tsx:225-231). - Description: FR7 and its verification row read as quoted — verified (
Tooltip.spec.md:181,:267). - Description: the JSDoc and both doc files describe the reports — partly false:
Tooltip.doc.mjs:139omits the held-open leave report. - Description: the pinned-tooltip story says the app also agrees to leave requests — verified.
- Description: the changeset is a core minor, breaking, with a migration — verified.
- Description: an uncontrolled tooltip, or a controlled one that already ignores requests, is unchanged — partly false: Core's cut-label tooltip agrees to every hide report and now closes on a mouse leave.
- Description: red first, the new cases fail on
mainand pass here — verified (six fail on the base, all pass at the head). - Description: the Tooltip and Comments suites pass — verified.
- Description: writing rubric results — consistent: FR7 is present tense with no project status.
.changeset/tooltip-controlled-leave-report.md— finding (overclaim).apps/storybook/stories/LayerDismissal.stories.tsx— clear.docs/specs/components/Tooltip/Tooltip.spec.md— finding (FR7 awaits owner approval; compatibility section and untested-claims line).packages/core/src/Tooltip/Tooltip.doc.mjs— finding (leave report missing).packages/core/src/Tooltip/Tooltip.test.tsx— clear (focus-leave case would help).packages/core/src/Tooltip/Tooltip.tsx— clear (JSDoc matches the head behavior).packages/core/src/Tooltip/useTooltip.doc.mjs— clear.packages/core/src/Tooltip/useTooltip.test.tsx— clear.packages/core/src/Tooltip/useTooltip.tsx— findings (cut-label regression through the leave report, lint, desktop decision, two comments that restate the code).packages/lab/src/Comments/Comments.test.tsx— clear.
| const latest = latestRef.current; | ||
| if (latest.isOpen === true) { | ||
| latest.onHide?.(); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Regression: this report also reaches Core's UndescribedTooltip (Tooltip.tsx:386-395), which holds isOpen: true and closes on every onHide. So with keyboard focus on a Button whose label is cut (or a Table header whose heading is cut), a mouse that passes over it and away removes the full-label tooltip 100 ms later while focus stays, which breaks the tooltip's persistence for focus-triggered content. Please keep that tooltip open through a pointer leave (its onHide is meant for Escape) and add a case to Button.truncationTooltip.test.tsx where the mouse crosses the focused Button.
| showLayer(); | ||
| }, delay); | ||
| }, [isEnabled, isOpen, clearTimeouts, showLayer, delay]); | ||
| }, [isEnabled, clearTimeouts, showLayer, delay]); |
There was a problem hiding this comment.
Miss: strict lint (as CI runs it) reports @eslint-react/exhaustive-deps here and at line 518: latestRef is read in the timer callbacks but missing from the dependency arrays. Adding it, as handleFocusIn does, clears both errors.
Summary
A Tooltip wired to state (
isOpen={open} onOpenChange={setOpen}) behaves like an uncontrolled one: it opens on hover and closes when the pointer or focus leaves. Today it does neither. A held-closed hover reports nothing, and a held-open tooltip ignores leaves without a report. So a state-wired tooltip never opens on hover, and one held open by state never hears a leave.Lab's copy-link tooltip in
CommentActions(isOpen={isLinkCopied || isLinkTooltipOpen}withonOpenChange={setIsLinkTooltipOpen}) is one of these: on current main it never opens on hover. With this change it opens on hover and closes once the pointer leaves.What changes
useTooltip:delaycallsonShowonce and shows nothing; a pointer leaving before the delay drops the report.onHideafter the hide delay and hides nothing.onOpenChange.component:TooltipFR7: "A controlled tooltip answers Escape, and withisOpen={true}a pointer leave or focus leave that would hide it, by callingonOpenChange(false)without hiding … a controlled tooltip reports hover or focus intent by callingonOpenChange(true)without showing". The verification row covers a state-wired tooltip.isOpen,onShowandonHideJSDoc and both doc files describe the reports.[breaking], with a migration.Who is affected, and the migration
onOpenChangecall now loses the tip when the pointer or focus leaves the trigger. To keep it pinned, ignoreonOpenChange(false)while pinned and close it from your own control.onOpenChange(true)until the app allows it again.Tests
Writing rubric results
Owner: fix-loop lane 4. Land path: Drain merges after CodeBunny, Specs and CI.