Skip to content

feat(Tooltip): a trigger whose tooltip repeats its own text pins without toggle state - #9361

Closed
vjeux wants to merge 1 commit into
meta:mainfrom
vjeux:feat/tooltip-own-text-pin
Closed

vjeux wants to merge 1 commit into
meta:mainfrom
vjeux:feat/tooltip-own-text-pin

Conversation

@vjeux

@vjeux vjeux commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Status: draft, on main 9ae589b, which carries #9232 and #9406. This branch carries only this change (ed6c6cf). It edits Tooltip.spec.md, so it needs its own /approve-spec at this head (pending). Every gate under Testing ran at this head, on main 9ae589b.

Review this pull request's change: https://github.com/meta/astryx/pull/9361/files

User need

A truncated Text that is its own tab stop has a tooltip that repeats its full text. Under triggerBehavior="toggle", component:Tooltip FR9 lets that trigger pin its tooltip without being a button, so touch and keyboard users can keep the full text open. It gets no toggle state and no announcement, since its text is already the trigger's content.

Problem and solution fit

  • An internal repeatsTriggerText option on the shared press pin, passed through useTooltipInternal, pins such a trigger on a press. It gets no development warning, no aria-expanded or aria-controls, and no announcement (FR9's own-text clause). The option joins the pin's settle key and its re-wire Effect, so turning it on after mount wires the trigger.
  • Such a trigger is not a nested button, so an Astryx clickable container or row wouldn't skip its press on its own. Neither would an anchored role="button" element, which an Item row's own check misses. The pin marks each click it answers, and every Astryx clickable surface ignores a marked click: useClickableContainer (ClickableCard, SelectableCard, TokenLink, FileInput, Overlay, and link rows), Item rows, TreeList rows, and the Table row-expansion and tree-data row clicks.

Current specification

component:Tooltip FR9, its own-text clause, current at 1d8696a (#9175). The prop's name and values, triggerBehavior ('adaptive' | 'hover' | 'toggle', default 'adaptive'), are the records pull request #9379's, merged as a68e0e3; this pull request is built on it, and the record lines it changes already use #9379's wording. The row change follows FR9's sentence from #9232: with anchorRef, or useTooltip with a caller's trigger, "Astryx clickable rows, cards, and containers ignore" the pinning press.

Public delta and caller burden

No API change. The repeatsTriggerText option is internal (useTooltipInternal is @internal), and no component passes it yet. One observable change: an anchored or hook-wired role="button" trigger that is not a native button now pins inside an Item row without running the row, as FR9 states. TreeList rows, click-expanding Table rows, and the useClickableContainer surfaces already skipped such a trigger; their new check covers the internal own-text trigger. There is no caller burden. It is unreleased, and ships in the same release as #9232.

API changes

None.

Design and alternatives

  • The option lives on the shared press pin, beside the button test it relaxes: a repeat trigger gets the press listeners but no toggle state.
  • The click mark lives in its own module, Layer/pressPinClick.ts, with no imports. Rows and containers read it without loading the press pin, so their bundles don't grow.

Evidence

  • Red first: With main's rows and containers (no press-pin check), 6 cases fail: the ClickableCard case, the anchored role="button" trigger in an Item row, and the own-text trigger in an Item row, a TreeList row, a Table row that expands on click, and a tree-data row. With repeatsTriggerText left out of the settle key and the re-wire Effect, the after-mount case fails.
  • Layer/usePressPin.test.tsx:
    • a trigger whose tooltip repeats its own text pins without being a button, with no warning, toggle state, or announcement, and Enter closes it;
    • inside an Astryx ClickableCard, with no wrapper to stop the press, the card does not open;
    • an anchored role="button" trigger in an Item row pins, and the row does not activate;
    • an own-text trigger in an Item row, a TreeList row, a Table row that expands on click, and a tree-data Table row pins, and the row stays as it was;
    • a tooltip that starts repeating its trigger text after mount wires its trigger, so a press pins it.
  • Records: Tooltip's FR9 gap note returns to "no component reaches the own-text clause yet". Its current-state item returns to "No trigger reaches FR9's own-text pin yet" (an internal option that no component passes yet), and its verification row drops the own-text evidence-gap note. FR9's Item-row gap sentence and its current-state item go, since Item now reads the press-pin mark; the compatibility count returns to eleven. The Item-row exception that feat(Tooltip): triggerBehavior="toggle" pins the tooltip on a press #9232's changeset, Tooltip and useTooltip JSDoc, and Tooltip.doc.mjs (English and Chinese) and useTooltip.doc.mjs texts name goes as well.

Why it is split

#9232 was over the 2,000-line review threshold, and this unit separates cleanly. No component passes the option yet. This pull request is 14 files, +373/−64. All five (#9232, #9406, this one, #9291, and #9246) ship in the same release.

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Focused tests ship with the feature; it is internal, so there are no consumer docs or migration.
  • Public text and artifacts contain no internal Meta context.

Writing rubric results

The rubric in docs/contributing/spec-writing.md, over the changed parts of Tooltip.spec.md:

  • R1 narration: none; the gap note and the current-state item state what is built and what no component reaches yet.
  • R2 research in the record: none.
  • R3 evidence naming a change: none; the verification cell names test files.
  • R4 rejected alternatives over one line or outside a decision: none.
  • R5 pull request or issue references remaining: none.
  • R6 ruled open questions still listing options: none.

Testing

Local gates at this head, ed6c6cf (on main 9ae589b):

  • These pass: pnpm check:knowledge, pnpm check:changesets, pnpm check:i18n-runtime, core tsc (0 errors), ASTRYX_STRICT_LINT=1 pnpm lint (0 errors), Prettier on the touched files, and the Storybook build. The touched .doc.mjs files stay unformatted, as on main, and load.
  • usePressPin.test.tsx and usePressPin.calls.test.tsx: 48 of 48, with the red cases above failing on main's rows, containers, and settle key. The Layer, Tooltip, and HoverCard suites: 559 tests pass.
  • pnpm test:ui: 741 files, 18,479 tests pass.
  • pnpm test:node: 16,045 pass, with 2 expected failures.
  • TouchTrigger.a11y.chromium.spec.ts in Chromium: 21 of 21, twice.
  • In WebKit, Tooltip's two .a11y.browser.spec.ts specs, ten times each: 220 of 220. They run in the CI profile: the Playwright 1.61.1 image, 4 CPUs, CI=1, LP_NUM_THREADS=4, and one worker.

@vercel

vercel Bot commented Nov 1, 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 3, 2026 1:56am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 1, 2026
@astracat-bot

astracat-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 2:08 AM UTC

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

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

This needs an engineering-owner decision before it can be approved. The head rewrites component:Tooltip FR9 so that, with anchorRef or a useTooltip caller's trigger, a plain onClick ancestor still receives the pinning press, and the current FR9 stop clause does not allow that. An engineering owner records the decision by commenting /approve-spec followed by the full head SHA on this pull request, and the author may do so as an engineering owner. Whatever the decision, these still need changes:

  • An own-text trigger inside a Table row that expands on click also expands the row. The press-pin guard is only in useClickableContainer, not in the Table row handlers that share its checks.
  • The changeset says a clickable row around a useTooltip trigger does nothing, but a plain onClick row still receives the press from the hook.
  • With #9232's commit included, this is 2,068 authored lines. Landing #9232 first and rebasing would leave only this change's 163 lines.

[Automated review]

| 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 `pressTrigger="toggle"`, 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. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, any focus FR4 opens on, keyboard focus or a click into a text-field trigger, still opens the tooltip and reports `onOpenChange(true)`, and Escape then only reports `onOpenChange(false)`, so it stays until focus or the pointer leaves the trigger or the tooltip, or the caller re-renders with a new `onOpenChange` (Current-state impact). `isEnabled={false}` disables triggers and drops a pending open. | Current source and tests |
| FR8 | `onOpenChange` reports each show and hide. `hasHoverIndication` (`auto`: a single string or number child) adds a hover cue to the inline trigger. | Current source and tests |
| FR9 | With `pressTrigger="toggle"` and a trigger whose role is `button` (a `<button>` or `role="button"`), a click, a completed tap, Enter, or Space on the trigger pins the tooltip open, and the same press on a pinned tooltip closes it. Hover and keyboard focus still preview it per FR3 and FR4; on touch no preview opens and a tap pins it, while a touch that becomes a scroll pins nothing. A pinned tooltip stays open when the pointer leaves the trigger and the surface; Escape (FR6), a second press, a press outside the trigger and the surface, or focus moving outside them closes it. In a controlled tooltip a press reports the toggled value through `onOpenChange` and does not change the state itself (FR7). A press that pins or closes the layer stops at its trigger: it does not reach a clickable row, card, or container around it, or the control a label names. With `anchorRef`, or `useTooltip` with a caller's trigger, the caller's own handlers still receive the press: the anchor's `onClick` runs, and a plain `onClick` element around the anchor receives it unless the anchor's `onClick` stops it; Astryx clickable rows, cards, and containers ignore it. A trigger whose role is not `button` gets a development warning and keeps tap-only opening: a tap opens the tooltip as `touchTrigger="tap"` does, and no press pins it. A trigger whose tooltip repeats its own visible text, such as a truncated Text that is its own tab stop, may take `pressTrigger="toggle"` without being a button: a press pins it as on a button trigger, and it gets no development warning, no `aria-expanded` or `aria-controls`, and no announcement, since its text is already its content. Implementation gap: no component reaches the own-text clause yet (Current-state impact). | DEC-1; WCAG 1.4.13, 2.1.1 |

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.

The new sentence "With anchorRef, or useTooltip with a caller's trigger, … a plain onClick element around the anchor receives it" is a carve-out from the current FR9 stop clause ("does not reach a clickable row, card, or container around it"). An engineering owner needs to approve it, or the anchorRef and hook paths need to conform.

if (disabled) {
// A press that pinned or closed a hover layer stops at its trigger: the
// container does not act on it (component:Tooltip FR9).
if (disabled || isPressPinClick(event.nativeEvent)) {

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.

The guard only covers the hook's own onClick. The Table row-expansion and tree-data row clicks share this hook's checks through hasInteractiveAncestor and miss it, so an own-text trigger in a clickable Table row both pins and expands the row. Moving the check into the shared predicate, or adding it to both row handlers, keeps the three surfaces aligned.

Comment thread .changeset/press-trigger-toggle.md Outdated
'@astryxdesign/core': patch
---

[feat] Tooltip (and `useTooltip`) take `pressTrigger` (type `TooltipPressTrigger`): `none` (the default, unchanged) or `toggle`. With `toggle` on a button trigger, a click, a tap, Enter, or Space pins the tooltip open and the same press closes it, while hover and focus still preview it. A pinned tooltip stays until Escape, a second press, a press outside, or focus leaving, and it takes Escape before the layer beneath it. The press stops at its trigger, so a clickable row, card, or label around it does nothing, and the trigger's own handlers still run. With `anchorRef`, Tooltip renders nothing around the trigger to stop it: the anchor's own `onClick` runs, Astryx clickable rows, cards, and containers ignore the press, and a plain `onClick` element around the anchor receives it unless the anchor's `onClick` stops it. The trigger reports `aria-expanded` and `aria-controls`, and the tooltip's text is announced once when it pins, inside a modal too (`component:Tooltip` FR9 and FR10). A trigger that is not a button gets a development warning and keeps tap-only opening; beside `pressTrigger="toggle"`, `touchTrigger` is ignored.

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.

For useTooltip, "a clickable row, card, or label around it does nothing" is not what the hook does: a plain onClick row still receives the press (the head's useTooltip.doc.mjs says so). Naming useTooltip beside anchorRef in the exception sentence fixes it.

@vjeux
vjeux force-pushed the feat/tooltip-own-text-pin branch from d35f344 to f3f40ea Compare November 2, 2026 00:43
@github-actions github-actions Bot removed the needs:design-review Affects visuals — Design should review label Nov 2, 2026

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

This needs an engineering-owner decision before it can be approved: the head adds a sentence to component:Tooltip FR9 under which a plain onClick element around an anchorRef or useTooltip trigger still receives the pinning press, and the current FR9 stop clause does not allow that. An engineering owner records the decision by commenting /approve-spec followed by the full head SHA on this pull request (the author may do so as an engineering owner), or asks for the anchorRef and hook paths to conform. Whatever the decision, these still need changes:

  • An own-text trigger pins and also activates an Item or TreeList row with onClick or a Table row that expands on click, and an anchored role="button" trigger activates an Item row, because only useClickableContainer reads the press-pin mark.
  • The re-wire Effect in usePressPin.ts leaves repeatsTriggerText out of its settle key and dependencies, so turning the option on after mount never wires the trigger.
  • With #9232 and #9406 included this is 2,286 authored lines; landing them first and rebasing onto main, which also clears the conflicts in Tooltip.spec.md, useTooltip.tsx and useTooltip.doc.mjs, leaves this change's 163 lines.

[Automated review]

if (disabled) {
// A press that pinned or closed a hover layer stops at its trigger: the
// container does not act on it (component:Tooltip FR9).
if (disabled || isPressPinClick(event.nativeEvent)) {

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.

This is the only place the press-pin mark is read. An Item row with onClick (Item.tsx handleContainerClick), a TreeList row with onClick (TreeListItem.tsx handleClick) and the Table row-expansion and tree-data rows don't go through this onClick, so an own-text trigger pins and also activates those rows, and an anchored role="button" trigger activates an Item row. Reading the mark in the walk they share (or in each handler) keeps FR9's stop clause for all of them.

Comment thread packages/core/src/Layer/usePressPin.ts Outdated
// it here: the host's ref callback does not run again for that change.
useEffect(() => {
wire(offeredRef.current);
}, [triggerBehavior, wire]);

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.

wire reads repeatsTriggerText, but neither this Effect's dependencies nor the settle key (element and triggerBehavior) include it, so a tooltip whose repeatsTriggerText turns true after mount never wires its trigger. Adding it to both fixes that.

| 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 `triggerBehavior="toggle"`, 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. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, any focus FR4 opens on, keyboard focus or a click into a text-field trigger, still opens the tooltip and reports `onOpenChange(true)`, and Escape then only reports `onOpenChange(false)`, so it stays until focus or the pointer leaves the trigger or the tooltip, or the caller re-renders with a new `onOpenChange` (Current-state impact). `isEnabled={false}` disables triggers and drops a pending open. | Current source and tests |
| FR8 | `onOpenChange` reports each show and hide. `hasHoverIndication` (`auto`: a single string or number child) adds a hover cue to the inline trigger. | Current source and tests |
| FR9 | With `triggerBehavior="toggle"` and a trigger whose role is `button` (a `<button>` or `role="button"`), a click, a completed tap, Enter, or Space on the trigger pins the tooltip open, and the same press on a pinned tooltip closes it. Hover and keyboard focus still preview it per FR3 and FR4; on touch no preview opens and a tap pins it, while a touch that becomes a scroll pins nothing. A pinned tooltip stays open when the pointer leaves the trigger and the surface; Escape (FR6), a second press, a press outside the trigger and the surface, or focus moving outside them closes it. In a controlled tooltip a press reports the toggled value through `onOpenChange` and does not change the state itself (FR7). A press that pins or closes the layer stops at its trigger: it does not reach a clickable row, card, or container around it, or the control a label names. With `anchorRef`, or `useTooltip` with a caller's trigger, the caller's own handlers still receive the press: the anchor's `onClick` runs, and a plain `onClick` element around the anchor receives it unless the anchor's `onClick` stops it; Astryx clickable rows, cards, and containers ignore it. A trigger whose role is not `button` gets a development warning and keeps tap-only opening: every completed tap opens the tooltip, and no press pins it. A trigger whose tooltip repeats its own visible text, such as a truncated Text that is its own tab stop, may take `triggerBehavior="toggle"` without being a button: a press pins it as on a button trigger, and it gets no development warning, no `aria-expanded` or `aria-controls`, and no announcement, since its text is already its content. Implementation gap: no component reaches the own-text clause yet (Current-state impact). | DEC-1; WCAG 1.4.13, 2.1.1 |

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.

The new sentence "With anchorRef, or useTooltip with a caller's trigger, … a plain onClick element around the anchor receives it" is an exception to the current stop clause ("does not reach a clickable row, card, or container around it"). It needs an engineering owner's /approve-spec for this head, or the anchorRef and hook paths should conform.

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

This needs an engineering-owner decision before it can be approved: the head adds a sentence to component:Tooltip FR9 under which a plain onClick element around an anchorRef or useTooltip trigger still receives the pinning press, and the current FR9 stop clause does not allow that. An engineering owner records the decision by commenting /approve-spec followed by the full head SHA on this pull request (the author may do so as an engineering owner), or asks for the anchorRef and hook paths to conform. Whatever the decision, these still need changes:

  • An own-text trigger pins and also runs an Item or TreeList row with onClick or a Table row that expands on click, and an anchored role="button" trigger runs an Item row, because only useClickableContainer reads the press-pin mark.
  • The re-wire Effect in usePressPin.ts leaves repeatsTriggerText out of its settle key and dependencies, so turning the option on after mount never wires the trigger.
  • With #9232 and #9406 included this is 2,360 authored lines; landing them first and rebasing leaves this change's 163 lines.

[Automated review]

if (disabled) {
// A press that pinned or closed a hover layer stops at its trigger: the
// container does not act on it (component:Tooltip FR9).
if (disabled || isPressPinClick(event.nativeEvent)) {

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.

This is the only place the press-pin mark is read. An Item row with onClick (Item.tsx handleContainerClick), a TreeList row with onClick (TreeListItem.tsx handleClick) and the Table row-expansion and tree-data row clicks (hasInteractiveAncestor) never call this onClick, so on this head an own-text trigger pins and also runs those rows, and an anchored <span role="button"> runs an Item row. A shared check here that answers true for isPressPinClick(event.nativeEvent), called from those four handlers, would cover them; Item, TreeList and Table row cases beside the ClickableCard one would prove it.

Comment thread packages/core/src/Layer/usePressPin.ts Outdated
Comment on lines +522 to +524
useEffect(() => {
wire(offeredRef.current);
}, [triggerBehavior, wire]);

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.

wire reads repeatsTriggerText (line 475), but neither this Effect's dependencies nor the settle key (element and triggerBehavior, lines 462-470) include it, so a tooltip whose repeatsTriggerText turns true after mount never wires its trigger and a click pins nothing. Adding it to both fixes it.

| 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 `triggerBehavior="toggle"`, 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. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, any focus FR4 opens on, keyboard focus or a click into a text-field trigger, still opens the tooltip and reports `onOpenChange(true)`, and Escape then only reports `onOpenChange(false)`, so it stays until focus or the pointer leaves the trigger or the tooltip, or the caller re-renders with a new `onOpenChange` (Current-state impact). `isEnabled={false}` disables triggers and drops a pending open. | Current source and tests |
| FR8 | `onOpenChange` reports each show and hide. `hasHoverIndication` (`auto`: a single string or number child) adds a hover cue to the inline trigger. | Current source and tests |
| FR9 | With `triggerBehavior="toggle"` and a trigger whose role is `button` (a `<button>` or `role="button"`), a click, a completed tap, Enter, or Space on the trigger pins the tooltip open, and the same press on a pinned tooltip closes it. Hover and keyboard focus still preview it per FR3 and FR4; on touch no preview opens and a tap pins it, while a touch that becomes a scroll pins nothing. A pinned tooltip stays open when the pointer leaves the trigger and the surface; Escape (FR6), a second press, a press outside the trigger and the surface, or focus moving outside them closes it. In a controlled tooltip a press reports the toggled value through `onOpenChange` and does not change the state itself (FR7). A press that pins or closes the layer stops at its trigger: it does not reach a clickable row, card, or container around it, or the control a label names. With `anchorRef`, or `useTooltip` with a caller's trigger, the caller's own handlers still receive the press: the anchor's `onClick` runs, and a plain `onClick` element around the anchor receives it unless the anchor's `onClick` stops it; Astryx clickable rows, cards, and containers ignore it. A trigger whose role is not `button` gets a development warning and keeps tap-only opening: every completed tap opens the tooltip, and no press pins it. A trigger whose tooltip repeats its own visible text, such as a truncated Text that is its own tab stop, may take `triggerBehavior="toggle"` without being a button: a press pins it as on a button trigger, and it gets no development warning, no `aria-expanded` or `aria-controls`, and no announcement, since its text is already its content. Implementation gap: no component reaches the own-text clause yet (Current-state impact). | DEC-1; WCAG 1.4.13, 2.1.1 |

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.

The new sentence "With anchorRef, or useTooltip with a caller's trigger, … a plain onClick element around the anchor receives it" is an exception to the current stop clause ("does not reach a clickable row, card, or container around it"). It needs an engineering owner's decision at this head, or the anchorRef and hook paths need to conform. Separately, "Astryx clickable rows, cards, and containers ignore it" does not hold yet for Item rows with a role="button" anchor.

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

This needs an engineering-owner decision before it can be approved. The head adds a sentence to component:Tooltip FR9 under which a plain onClick element around an anchorRef or useTooltip trigger still receives the pinning press, which the current FR9 stop clause does not allow. An engineering owner records the decision by commenting /approve-spec followed by the full head SHA on this pull request (the author may do so as an engineering owner), or asks for the anchorRef and hook paths to conform. Whatever the decision, these still need changes:

  • An anchored role="button" trigger in an Item row, and an own-text trigger in an Item or TreeList row or a Table row that expands on click, pins the tooltip and also runs the row because only useClickableContainer reads the press-pin mark, although the changeset and docs say Astryx rows ignore the press.
  • The re-wire Effect in usePressPin.ts leaves repeatsTriggerText out of its settle key and dependencies, so turning it on after mount never wires the trigger.
  • With the stacked toggle work included this is 2,360 authored lines; landing those pull requests first and rebasing leaves this change's 163 lines.

[Automated review]

if (disabled) {
// A press that pinned or closed a hover layer stops at its trigger: the
// container does not act on it (component:Tooltip FR9).
if (disabled || isPressPinClick(event.nativeEvent)) {

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.

This is the only place the press-pin mark is read. Item rows with onClick (Item.tsx handleContainerClick), TreeList rows with onClick (TreeListItem.tsx handleClick) and the Table row-expansion and tree-data row clicks never call this onClick. On this head an anchored <span role="button"> trigger pins and also runs an Item row, and an own-text trigger runs all four. One shared check that answers true for isPressPinClick(event.nativeEvent), called from those handlers too, keeps FR9's stop for every Astryx row.

Comment thread packages/core/src/Layer/usePressPin.ts Outdated
Comment on lines +522 to +524
useEffect(() => {
wire(offeredRef.current);
}, [triggerBehavior, wire]);

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.

wire reads repeatsTriggerText (line 475), but neither this Effect's dependencies nor the settle key (lines 462-470, element and triggerBehavior) include it. A tooltip whose repeatsTriggerText turns true after mount never wires its trigger, so a click pins nothing. Adding it to both fixes this.

Comment thread .changeset/trigger-behavior-toggle.md Outdated
'@astryxdesign/core': patch
---

[feat] Tooltip (and `useTooltip`) take `triggerBehavior` (type `TooltipTriggerBehavior`): `adaptive`, the default and the released behavior, where hover and focus preview the tooltip and a tap opens it unless the trigger performs an action of its own; `hover`, where hover and focus preview it and no touch or pen tap opens it; or `toggle`, where hover and focus still preview it and a click, a tap, Enter, or Space on a button trigger pins it open, and the same press closes it. A pinned tooltip stays until Escape, a second press, a press outside, or focus leaving, and it takes Escape before the layer beneath it. The press stops at its trigger, so a clickable row, card, or label around it does nothing, and the trigger's own handlers still run. With `anchorRef`, or `useTooltip` with a caller's trigger, nothing is rendered around the trigger to stop it: the trigger's own `onClick` runs, Astryx clickable rows, cards, and containers ignore the press, and a plain `onClick` element around the trigger receives it unless the trigger's `onClick` stops it. The trigger reports `aria-expanded` and `aria-controls`, and the tooltip's text is announced once when it pins, inside a modal too (`component:Tooltip` FR9 and FR10). A trigger that is not a button gets a development warning and keeps tap-only opening; `touchTrigger` decides taps only under `adaptive`; `hover` and `toggle` ignore it.

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.

"Astryx clickable rows, cards, and containers ignore the press" does not hold yet: an anchored role="button" trigger inside an Item row with onClick still runs the row. Either extend the guard to Item, TreeList and Table rows, or narrow this to the surfaces built on useClickableContainer's onClick.

| 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 `triggerBehavior="toggle"`, 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. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, any focus FR4 opens on, keyboard focus or a click into a text-field trigger, still opens the tooltip and reports `onOpenChange(true)`, and Escape then only reports `onOpenChange(false)`, so it stays until focus or the pointer leaves the trigger or the tooltip, or the caller re-renders with a new `onOpenChange` (Current-state impact). `isEnabled={false}` disables triggers and drops a pending open. | Current source and tests |
| FR8 | `onOpenChange` reports each show and hide. `hasHoverIndication` (`auto`: a single string or number child) adds a hover cue to the inline trigger. | Current source and tests |
| FR9 | With `triggerBehavior="toggle"` and a trigger whose role is `button` (a `<button>` or `role="button"`), a click, a completed tap, Enter, or Space on the trigger pins the tooltip open, and the same press on a pinned tooltip closes it. Hover and keyboard focus still preview it per FR3 and FR4; on touch no preview opens and a tap pins it, while a touch that becomes a scroll pins nothing. A pinned tooltip stays open when the pointer leaves the trigger and the surface; Escape (FR6), a second press, a press outside the trigger and the surface, or focus moving outside them closes it. In a controlled tooltip a press reports the toggled value through `onOpenChange` and does not change the state itself (FR7). A press that pins or closes the layer stops at its trigger: it does not reach a clickable row, card, or container around it, or the control a label names. With `anchorRef`, or `useTooltip` with a caller's trigger, the caller's own handlers still receive the press: the anchor's `onClick` runs, and a plain `onClick` element around the anchor receives it unless the anchor's `onClick` stops it; Astryx clickable rows, cards, and containers ignore it. A trigger whose role is not `button` gets a development warning and keeps tap-only opening: every completed tap opens the tooltip, and no press pins it. A trigger whose tooltip repeats its own visible text, such as a truncated Text that is its own tab stop, may take `triggerBehavior="toggle"` without being a button: a press pins it as on a button trigger, and it gets no development warning, no `aria-expanded` or `aria-controls`, and no announcement, since its text is already its content. Implementation gap: no component reaches the own-text clause yet (Current-state impact). | DEC-1; WCAG 1.4.13, 2.1.1 |

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.

The new sentence "With anchorRef, or useTooltip with a caller's trigger, … a plain onClick element around the anchor receives it" is an exception to the current stop clause ("does not reach a clickable row, card, or container around it"). It needs an engineering owner's decision at this head, or the anchorRef and hook paths need to conform.

@vjeux
vjeux force-pushed the feat/tooltip-own-text-pin branch from 91a3809 to eadb464 Compare November 3, 2026 00:06
@vjeux

vjeux commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated in eadb464, restacked on #9406's 795ae5a. #9232 now records the Item-row gap in FR9, with a current-state item, and names it in its changeset, docs and JSDoc; this change removes all of them with the fix.

  • Astryx rows: the pin's click mark now lives in Layer/pressPinClick.ts. Item rows, TreeList rows, and the Table row-expansion and tree-data row clicks read it, as useClickableContainer does. An anchored role="button" trigger in an Item row, and an own-text trigger in each of those rows, now pins without running the row, with a test each.
  • repeatsTriggerText after mount: the option joins the settle key and the re-wire Effect's dependencies, with a test that turns it on after mount.
  • Approval: this pull request's own record change is FR9's own-text gap note, the current-state item, and the verification row. It needs a spec owner's /approve-spec eadb464c88bc545a250601340128a66eb21b11b5 here. FR9's anchorRef/useTooltip sentence is feat(Tooltip): triggerBehavior="toggle" pins the tooltip on a press #9232's, unchanged.
  • Size: this change alone is 14 files, +374/−64.

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

This needs an engineering-owner decision before it can be approved. The head adds a sentence to component:Tooltip FR9, and an "FR9 (anchorRef)" verification row, under which a plain onClick element around an anchorRef or useTooltip trigger still receives the pinning press, while the current FR9 says that press stops at its trigger and does not reach a clickable row, card, or container around it. An engineering owner settles it by commenting /approve-spec followed by the full head SHA on this pull request (the author can do this as an engineering owner), or by asking for the anchorRef and hook paths to conform to the current stop clause.

Still required either way:

  • With the stacked toggle work included, this pull request is 2,797 authored lines; landing the two stacked pull requests first and rebasing leaves this change's 438 lines.

The earlier row-guard, changeset wording and re-wire Effect findings are fixed, and two non-blocking comment suggestions are inline.

[Automated review]

| 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 `triggerBehavior="toggle"`, 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. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, any focus FR4 opens on, keyboard focus or a click into a text-field trigger, still opens the tooltip and reports `onOpenChange(true)`, and Escape then only reports `onOpenChange(false)`, so it stays until focus or the pointer leaves the trigger or the tooltip, or the caller re-renders with a new `onOpenChange` (Current-state impact). `isEnabled={false}` disables triggers and drops a pending open. | Current source and tests |
| FR8 | `onOpenChange` reports each show and hide. `hasHoverIndication` (`auto`: a single string or number child) adds a hover cue to the inline trigger. | Current source and tests |
| FR9 | With `triggerBehavior="toggle"` and a trigger whose role is `button` (a `<button>` or `role="button"`), a click, a completed tap, Enter, or Space on the trigger pins the tooltip open, and the same press on a pinned tooltip closes it. Hover and keyboard focus still preview it per FR3 and FR4; on touch no preview opens and a tap pins it, while a touch that becomes a scroll pins nothing. A pinned tooltip stays open when the pointer leaves the trigger and the surface; Escape (FR6), a second press, a press outside the trigger and the surface, or focus moving outside them closes it. In a controlled tooltip a press reports the toggled value through `onOpenChange` and does not change the state itself (FR7). A press that pins or closes the layer stops at its trigger: it does not reach a clickable row, card, or container around it, or the control a label names. With `anchorRef`, or `useTooltip` with a caller's trigger, the caller's own handlers still receive the press: the anchor's `onClick` runs, and a plain `onClick` element around the anchor receives it unless the anchor's `onClick` stops it; Astryx clickable rows, cards, and containers ignore it. A trigger whose role is not `button` gets a development warning and keeps tap-only opening: every completed tap opens the tooltip, and no press pins it. A trigger whose tooltip repeats its own visible text, such as a truncated Text that is its own tab stop, may take `triggerBehavior="toggle"` without being a button: a press pins it as on a button trigger, and it gets no development warning, no `aria-expanded` or `aria-controls`, and no announcement, since its text is already its content. Implementation gap: no component reaches the own-text clause yet (Current-state impact). | DEC-1; WCAG 1.4.13, 2.1.1 |

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.

The new sentence "With anchorRef, or useTooltip with a caller's trigger, … a plain onClick element around the anchor receives it unless the anchor's onClick stops it" is an exception to the current FR9 stop clause ("does not reach a clickable row, card, or container around it"). It needs an engineering owner's /approve-spec at this head, or the anchorRef and hook paths need to conform. The verification row at line 325 and "around a child trigger" at line 324 go with it.

Comment thread packages/core/src/Layer/usePressPin.ts Outdated
setIsPinnedState(next);
}, []);

// Refs hold the wired trigger and last offered element for a later rewire.

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 (comment style): this restates triggerRef and offeredRef. Keep only the reason, for example "A mode change wires the last offered element again."

Comment thread packages/core/src/Layer/usePressPin.ts Outdated
[wire],
);

// A button, or any trigger whose layer repeats its own text.

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 (comment style): this restates the isWired expression below it; it can go.

…out toggle state

`component:Tooltip` FR9's own-text clause, on the shared press pin
(`Layer/usePressPin.ts`):

- usePressPin's internal `repeatsTriggerText` option, passed through
  useTooltipInternal (useTooltip with Core's internal options), pins a
  trigger whose tooltip repeats its own visible text, such as a truncated
  Text that is its own tab stop, without a button trigger: no development
  warning, no aria-expanded or aria-controls, and no announcement. The
  option joins the settle key and the re-wire Effect, so turning it on
  after mount wires the trigger.
- Astryx clickable containers and rows ignore a press-pin click: the mark
  lives in `Layer/pressPinClick.ts`, which useClickableContainer, Item rows,
  TreeList rows, and the Table row-expansion and tree-data row clicks read.
  So a trigger that is not a nested button, an own-text trigger or an
  anchored `role="button"` element, doesn't activate the card or row around
  it when no component wrapper stops the press.
- No component passes the option yet; the record keeps that implementation
  gap.
- With the gap closed, Tooltip's FR9 gap note, its current-state item, and the
  Item-row exception in the changeset, docs, and JSDoc go.
@vjeux
vjeux force-pushed the feat/tooltip-own-text-pin branch from eadb464 to ed6c6cf Compare November 3, 2026 01:48
@vjeux

vjeux commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 9ae589b, which carries #9232 and #9406, so this branch now carries only its own commit: ed6c6cf, 14 files, +373/−64.

This head needs a spec owner's /approve-spec ed6c6cfce93457f76965b02b5a96a96f5b810650.

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

Approval recommended: the Item, TreeList, Table row and clickable-container guards make the pinning press behave as component:Tooltip FR9 already states, and the internal own-text option matches FR9's own-text clause. The six new row and container tests fail against the base's rows and pass here.

  • Before merge, the Tooltip record edit still needs an engineering owner's spec approval at this head (/approve-spec <full head SHA>), and CI ran no jobs while the pull request is a draft.
  • Optional: the doc comment on the click set in packages/core/src/Layer/pressPinClick.ts only restates its name; delete it or keep a reason.

[Automated review]

* the mark without loading the press pin itself (usePressPin.ts).
*/

/** The clicks that a press pin answered. */

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 (comment style): this restates the name pressPinClicks, and the move dropped the reason the old comment carried. Delete it, or keep only a reason, for example "Weak, so no click outlives its dispatch."

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

Table-scoped review of exact head ed6c6cfce93457f76965b02b5a96a96f5b810650.

The historical Table row/tree guards correctly check the marked native event, and #9291 contains those exact ancestor Table blobs rather than another authored fix. Current main has since replaced the automatic pin/toggle owner and removed the internal mark producer. Reconcile the surviving Table requirement with the current Tooltip/InfoTip owner instead of reviving the removed triggerBehavior path merely to keep this guard live. No new Table source defect is asserted at this historical head. Draft/runtime evidence and current-owner integration remain held.

@vjeux

vjeux commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Agreed: main (#9756) replaced the automatic pin/toggle owner, so we won't revive the removed triggerBehavior path to keep this guard live. Any surviving Table requirement goes to the current Tooltip/InfoTip owner.

@vjeux

vjeux commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #9756, which replaced the automatic pin/toggle owner with useTooltip's show() and hide(). Thanks to humbertovirtudes for the Table review. Any Table guard still needed comes back as a small PR against the current Tooltip/InfoTip owner.

@vjeux vjeux closed this Nov 4, 2026
@vjeux
vjeux deleted the feat/tooltip-own-text-pin branch November 4, 2026 02:41

This branch was successfully deployed

1 active deployment
Preview — ed6c6cfc Deployed Nov 3, 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. needs:spec-owner-review Current knowledge records await owner approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants