Skip to content

feat(HoverCard): triggerBehavior="toggle" pins the card on a press - #9291

Closed
vjeux wants to merge 2 commits into
meta:mainfrom
vjeux:feat/hover-card-press-trigger
Closed

vjeux wants to merge 2 commits into
meta:mainfrom
vjeux:feat/hover-card-press-trigger

Conversation

@vjeux

@vjeux vjeux commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Status: draft, stacked on #9361 (ed6c6cf), on main 9ae589b, which carries #9232 and #9406. Until #9361 merges, this branch carries its commit and this change (bdde69a). This change edits HoverCard.spec.md, so it needs its own /approve-spec at this head (pending). The gates under Testing ran at b5931d2, which differs from this head by one comment line; the checks named at this head ran here.

Review only this pull request's change: vjeux/astryx@ed6c6cf...bdde69a

User need

A hover card that is the only home of its information (a profile card on an avatar button, the details behind an icon-only trigger) can't be kept open by touch, keyboard or screen-reader users. Hover opens it and leaving closes it; nothing pins it.

Problem and solution fit

  • triggerBehavior="toggle" makes the trigger a toggle, as it does for Tooltip in feat(Tooltip): triggerBehavior="toggle" pins the tooltip on a press #9232. On a button trigger, a click, a tap, Enter or Space pins the card, and the same press closes it. Hover and focus still preview it.
  • A pinned card is the person's own interaction, so it takes Escape before the layer beneath it (spec:AST-003 FR4, DEC-6).
  • The press stops at its trigger, so a toggle inside a clickable row, card or label doesn't also activate the container.

Current specification

component:HoverCard FR9, FR10, AR3 and DEC-1; spec:AST-003 FR4 and DEC-6. All are 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.

Public delta and caller burden

  • triggerBehavior: 'adaptive' | 'hover' | 'toggle' on HoverCard and useHoverCard, with the exported closed-union type HoverCardTriggerBehavior. Hover and focus preview the card under every value.
    • adaptive, the default, changes nothing: it is the released touch behavior, a tap opening the card unless the trigger performs an action of its own. Until CLN-0024 removes touchTrigger, an explicit touchTrigger still decides taps under it.
    • hover: touch never opens the card, and no press pins it (the released touchTrigger="none").
    • With toggle on a button trigger (a <button> or role="button"), a click, a tap, Enter or Space pins the card, and the same press closes it.
    • A pinned card stays when the pointer leaves, and a press on its own content keeps it. It closes on Escape, a second press, a press outside, a scroll that starts outside, or focus moving onto an element outside the trigger and the card, whatever focusTrigger is.
    • A controlled card reports the toggled value through onOpenChange and doesn't change itself. A controlled labelled card says its label each time its owner shows it pinned, and nothing for a press the owner declines.
    • The trigger carries aria-expanded (true only while pinned) and aria-controls while the card shows. When a press pins a card that has a label, the press handler says that label once; otherwise the card's rendered text is announced once by the shared rendered-text announcer (spec:AST-086 FR12), which keeps blocks apart and leaves hidden content out. Both reach a polite live region through useAnnounce, so inside a modal they're heard in the modal's own region (spec:AST-086 FR14).
    • On a trigger that is not a button, a labelled card keeps its own aria-expanded/aria-controls (FR3) and tap-only opening, with a development warning.
    • On the HoverCard component the press stops at its trigger: a clickable row, card or container around it doesn't activate. With useHoverCard and a caller's trigger, the caller's own handlers still receive the press: the trigger's onClick runs, Astryx clickable rows, cards and containers ignore it, and a plain onClick element around the trigger receives it unless the trigger's onClick stops it. HoverCard FR9 now states that clause, as Tooltip FR9 does for anchorRef and useTooltip. (approved on feat(Tooltip): triggerBehavior="toggle" pins the tooltip on a press #9232); it needs the spec owners' approval at this head.
    • A card whose triggerBehavior turns to adaptive while pinned closes on leave again.
    • Beside triggerBehavior="hover" or "toggle", touchTrigger is ignored.
<HoverCard content={<ProfileCard person={ada} />} label="Ada's profile" triggerBehavior="toggle">
  <button type="button">Ada</button>
</HoverCard>

API changes

Added public rows, decided by component:HoverCard FR9 and FR10 (#9175). They go to human review under architecture:public-component-api INV25. packages/core/api-report.md lists exactly these rows.

Change Package Signature Usage
added @astryxdesign/core HoverCardProps.triggerBehavior?: HoverCardTriggerBehavior (default 'adaptive') <HoverCard content={card} label="Profile" triggerBehavior="toggle"><button type="button">Ada</button></HoverCard>
added @astryxdesign/core HoverCardOptions.triggerBehavior?: HoverCardTriggerBehavior (default 'adaptive') useHoverCard({triggerBehavior: 'toggle'})
added @astryxdesign/core type HoverCardTriggerBehavior = 'adaptive' | 'hover' | 'toggle' const mode: HoverCardTriggerBehavior = 'toggle';

Design and alternatives

  • The card uses feat(Tooltip): triggerBehavior="toggle" pins the tooltip on a press #9232's press pin, Layer/usePressPin.ts, which owns the layer's touch trigger, so useHoverCard makes one usePressPin call (architecture:react-component-runtime INV16).
  • By the spec owners' ruling, a card's label is the dialog's name, a string and often shorter than the content, so the press handler says it through useAnnounce with no Effect; a card without one is announced from its rendered text through the shared announcer (architecture:react-component-runtime INV10).
  • On a trigger that is not a button the toggle stays off, so FR3's popup state stays the card's own (isPressPinTrigger).
  • HoverCardTriggerBehavior is a closed union, as TooltipTriggerBehavior is.
  • A controlled card's press only asks to pin it. So each time the owner shows the card pinned, with or without a press, the pin arms its outside dismissal and says the card's label, as an unlabelled card's rendered text is said. A press the owner declines says and arms nothing.

Evidence

  • Red first:
    • With main's sources, the pinned HoverCard cases in layerDismissalFamilies.test.tsx fail (2 of 2).
    • With feat(Tooltip): triggerBehavior="toggle" pins the tooltip on a press #9232's first head, a5250c6, a labelled card on a non-button trigger lost its own popup state.
    • With feat(Tooltip): triggerBehavior="toggle" pins the tooltip on a press #9232's second head, c543d57, an unlabelled card ran its paragraphs together ("Ada LovelaceAnalyst, Payments"), and a press on a pinned card's own text closed it (jsdom); the Chromium card case fails too (3 of 3 runs).
    • Announcing a labelled card's rendered text instead of its label fails the two labelled cases.
    • With feat(Tooltip): triggerBehavior="toggle" pins the tooltip on a press #9232's head 90ae917, the single-call case fails; with 40c79f0, a pinned card whose triggerBehavior turns to adaptive never closes on leave; with fc05aff, a focusTrigger="never" card stays pinned when focus moves away.
    • At this head, announcing a controlled card's label at the press fails the case where the owner keeps it closed, and so does arming the outside dismissal at the press (a press outside then reports a second onOpenChange). With a flag that waits for the press, an owner-opened card with no press says nothing, and the declined-then-opened case fails. Without the press's preventDefault and click mark, the Item-row stop case fails. The ClickableCard and <label> stop cases pass there too in jsdom: the card's container walk and jsdom's label activation already skip a button trigger.
  • HoverCard.test.tsx triggerBehavior on every input (24 cases): adaptive by default and explicitly, hover, and toggle, each under a mouse hover, focus, a tap on an info-only trigger (which opens it or never opens it), and a mouse click and a tap on a button trigger, which only the toggle pins; with touchTrigger beside each value. It fills HoverCard's "FR5, FR9 (triggerBehavior)" verification row. Without feat(Tooltip): triggerBehavior="toggle" pins the tooltip on a press #9232's hover mapping, 2 cases fail; with adaptive pinning a button as the toggle does, the four adaptive button cases fail.
  • HoverCard.test.tsx stop cases: a toggle press inside an Astryx ClickableCard, an Item row (with a role="button" trigger, which Item's row click does not skip by itself), and a <label> pins the card and activates nothing around it.
  • HoverCard.test.tsx useHoverCard caller-trigger cases: under the toggle, the trigger's own onClick runs and an Astryx ClickableCard around it does not activate; a plain onClick element around it receives the press unless the trigger's onClick stops it (HoverCard FR9's useHoverCard clause).
  • Layer/usePressPin.test.tsx (14 HoverCard tests): click, tap, Enter and Space pin; a second press, a press outside and focus leaving close it; pointer leave and presses on the card keep the pin, including a press on its own text that moves focus to no element; triggerBehavior turning to hover while pinned; focus moving away under focusTrigger="never"; a labelled card saying its label once when a press pins it, and a controlled one each time its owner shows it pinned, after a declined press too, and nothing for the declined press; an unlabelled card saying its own text once, paragraphs apart; the stop; a labelled card on a non-button trigger keeping its own popup state, with the development warning, and a tap still opening a card on such a trigger.
  • layerDismissalFamilies.test.tsx: an uncontrolled and a controlled pinned HoverCard over a Dialog each take Escape first, and the Dialog stays open.
  • Layer/usePressPin.calls.test.tsx: useHoverCard makes one usePressPin call per render, and every touch-trigger call comes from inside it.
  • hooks/useAnnounceRenderedText.adopters.test.tsx: an unlabelled HoverCard pinned by a press hands its text to the shared announcer and announces none of it itself; the registry check lists useHoverCard as an adopter.
  • TouchTrigger.a11y.chromium.spec.ts: under a mouse in Chromium, a pinned unlabelled card is announced as "Ada Lovelace Analyst, Payments", its paragraphs apart, and a click on its text keeps the pin (new HoverCardToggle story).
  • Records: HoverCard drops the "not yet built" notes on FR9, FR10 and AR3, and its "Toggle pinning is not built" current-state item; FR9 gains the useHoverCard clause, mirroring Tooltip FR9's approved anchorRef/useTooltip clause, for the spec owners' approval at this head; its verification rows cite the tests above (added to verified_by). system_specs adds spec:AST-086/FR12 and /FR14, and a path-applicability block links Layer/usePressPin.ts.

Why it is split

The HoverCard wiring (about 580 lines, under component:HoverCard FR9, FR10 and AR3) is its own pull request, stacked between #9361 (above #9406 and #9232) and #9246, by the maintainers' ruling. All five ship in the same release. This one is 16 files, +1,050/−100: HoverCard's wiring, its tests and story, its record and docs, its changeset, the shared hook's notes naming HoverCard, and HoverCard's API report rows. HoverCard fixes #9592, #9593, #9597, and #9603 touch the same files; whichever lands second rebases.

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • 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 HoverCard.spec.md:

  • R1 narration: none; the rows state what the card does.
  • R2 research in the record: none.
  • R3 evidence naming a change: none; the verification cells name test files and cases.
  • 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 b5931d2 (on #9361's ed6c6cf, on main 9ae589b). This head, bdde69a, changes one comment line in useHoverCard.tsx; at this head, core tsc (0 errors), strict ESLint and Prettier on that file, and the HoverCard, Layer, and hooks suites (1,146 tests) pass.

  • 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.
  • The API report: pnpm build and pnpm api:report --package core write exactly this pull request's four HoverCard rows. Apart from them, the regenerated file differs from the committed one only by main's own TextArea and TextInput rows (feat(TextInput,TextArea): tell a touch keyboard what the field holds #8166), which main's report also lacks.
  • The HoverCard, Layer, and hooks suites: 1,146 tests pass, with the red cases above failing without this change. The Layer, Tooltip, and HoverCard suites: 609 pass.
  • pnpm test:ui: 741 files, 18,530 tests pass.
  • pnpm test:node: 16,045 pass, with 2 expected failures.
  • TouchTrigger.a11y.chromium.spec.ts in Chromium: 22 of 22, twice, the HoverCard mouse case included.
  • 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 4:34am 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
❓ Needs maintainer input (for maintainers only) Nov 3, 2026, 4:49 AM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 1, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 1, 2026
@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.

Not ready yet: one owner decision and three fixes remain. An engineering owner needs to decide whether @astryxdesign/core should publish the new HoverCardPressTrigger and TooltipPressTrigger types, which no current record names; any engineering owner, the author included, can record that by commenting /approve-spec <full head SHA>.

  • With focusTrigger="never", a pinned card or tooltip stays open after focus moves away, contrary to FR9; letting the shared press pin listen for focusout on the trigger it wires fixes both components.
  • The diff still contains the unmerged #9232, so land it first and rebase until this pull request holds only the HoverCard change.
  • Both changesets say the press stops at the trigger for useHoverCard and useTooltip too, but with the hooks a plain onClick row still receives it.

[Automated review]

const handleFocusOut = useCallback(
(e: FocusEvent) => {
// A pinned card closes when focus leaves the trigger and the card.
if (handlePressFocusLeave(e)) {

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 way a pinned card learns that focus left, but the focusout listener that calls it is attached only when focusTrigger is always, or auto on a focusable trigger (lines 619-625). With focusTrigger="never", pressing Tab after pinning leaves the card open with aria-expanded="true", contrary to FR9's "focus moving outside them closes it". useTooltip.tsx:581-585 has the same gating.

}
return;
}
element.addEventListener('click', handlePress);

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.

Suggest wiring focusout here too, beside click and keydown, so the pin closes on focus leaving whatever the host's focusTrigger is, and the hosts can drop their trigger-side handlePressFocusLeave calls.

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

[feat] HoverCard (and `useHoverCard`) take `pressTrigger` (type `HoverCardPressTrigger`): `none` (the default, unchanged) or `toggle`. With `toggle` on a button trigger, a click, a tap, Enter, or Space pins the card open and the same press closes it, while hover and focus still preview it. A pinned card stays until Escape, a second press, a press outside, or focus leaving; a press on its own content keeps it, 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. The trigger reports `aria-expanded` and `aria-controls`, and the card's `label` (else its text) is announced once when it pins, inside a modal too (`component:HoverCard` FR9 and FR10). On a trigger that is not a button, a labelled card keeps its own popup state and 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.

"The press stops at its trigger, so a clickable row, card, or label around it does nothing" holds for the HoverCard component. It does not hold for useHoverCard, where a plain onClick row still receives the press (as useHoverCard.doc.mjs says). Suggest scoping this sentence to the component.

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

Same here: useTooltip callers inside a plain onClick row still get the row's click on a pinning press, and only the Tooltip component stops it.

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

Not ready yet: two engineering-owner decisions and four fixes remain. An engineering owner needs to approve or reject the new anchorRef exception this pull request writes into component:Tooltip FR9 (current FR9 says a pinning press never reaches a row or container around the trigger), and to decide whether @astryxdesign/core should publish HoverCardPressTrigger and TooltipPressTrigger; any engineering owner, the author included, can record approval by commenting /approve-spec <full head SHA>.

  • Land #9232 first and rebase, so this pull request holds only the HoverCard change instead of 2,716 authored lines.
  • Both changesets say the press stops at the trigger for useHoverCard and useTooltip too, but a plain onClick row around a bare hook trigger still activates; scope that sentence to the components.
  • A controlled labelled HoverCard announces its label as soon as a press asks it to open, even when the owner keeps it closed; announce only once it pins.
  • Add HoverCard stop cases inside a ClickableCard, an Item row and a <label>, which its verification row now claims.

[Automated review]

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

[feat] HoverCard (and `useHoverCard`) take `pressTrigger` (type `HoverCardPressTrigger`): `none` (the default, unchanged) or `toggle`. With `toggle` on a button trigger, a click, a tap, Enter, or Space pins the card open and the same press closes it, while hover and focus still preview it. A pinned card stays until Escape, a second press, a press outside, or focus leaving; a press on its own content keeps it, 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. The trigger reports `aria-expanded` and `aria-controls`, and the card's `label` (else its text) is announced once when it pins, inside a modal too (`component:HoverCard` FR9 and FR10). On a trigger that is not a button, a labelled card keeps its own popup state and 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.

"The press stops at its trigger, so a clickable row, card, or label around it does nothing" holds for the HoverCard component. With the bare useHoverCard hook a plain onClick row still receives the press (as useHoverCard.doc.mjs says). Suggest scoping this sentence to the component and saying what a hook caller does.

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.

Same for useTooltip: a plain onClick row around a bare hook trigger still gets the pinning press; only the Tooltip component stops it at a child trigger.

Comment thread packages/core/src/Layer/usePressPin.ts Outdated
if (current.isOpen !== undefined) {
if (!current.isOpen) {
armOutsideDismiss();
announceName();

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 a controlled layer this announces the label before the owner answers onOpenChange(true). If the owner keeps isOpen={false}, a screen-reader user hears the card's name while nothing opens and the trigger says aria-expanded="false". FR10 announces it "when the card pins"; consider announcing once the controlled card actually shows pinned, with a test where the owner declines.

| 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`, 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 added anchorRef sentence relaxes current FR9 ("does not reach a clickable row, card, or container around it"). That is a requirement change, so it needs an engineering owner's approval (/approve-spec <full head SHA>) or the anchored Tooltip has to stop the press as FR9 says today.

| FR3, AR1 | `HoverCard.test.tsx` role and trigger-attribute tests | Labelled and unlabelled; supported and unsupported roles | Wrong role, or trigger attributes that are not replaced and restored as stated, fail. | `audit:HoverCard/accessibility` |
| FR4–FR6, AR2 | `HoverCard.test.tsx` hover, Escape, refocus, and touch tests; `useTouchTrigger.test.ts` and `touchTriggerTargets.test.tsx` disabled-control cases; tap-destination cases an evidence gap until built | Hover, focus, tap, Escape from trigger and content; a trigger inside a link or a clickable card; a disabled control inside a clickable row | A card that cannot be reached or dismissed, or that opens on a tap that already acts, fails. | `audit:HoverCard/behavior` |
| FR7 | `HoverCard.test.tsx` isEnabled, isDefaultOpen, and onOpenChange tests; `layerDismissalFamilies.test.tsx` controlled HoverCard case | Disabled, default open | Wrong state reporting fails. | `audit:HoverCard/behavior` |
| FR9, FR10, AR3 | `usePressPin.test.tsx` HoverCard suites (click, Enter, Space, and tap pin; second press, press outside, and focus leaving close; pointer leave and presses on the card keep the pin; labelled and unlabelled announcements; a non-button trigger) and stop-at-trigger cases; `layerDismissalFamilies.test.tsx` pinned HoverCard over a Dialog, uncontrolled and controlled, closed by Escape | Click, Enter, Space, and tap pin; second press, press outside, focus leaving, and Escape close; pointer leave and presses on the card keep the pin; labelled and unlabelled; non-button trigger; a toggle trigger inside a ClickableCard, an Item row, and a `<label>` | A press that does not pin or close as stated, a pin lost on pointer leave, a missing or stale `aria-expanded` or `aria-controls`, a second announcement, a non-button trigger without the warning or its tap fallback, or a pinning press that also activates the card, row, or labelled control around the trigger, fails. | `audit:HoverCard/behavior` |

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 "stop-at-trigger cases" in usePressPin.test.tsx render Tooltip only; this row's ClickableCard, Item row and <label> states have no HoverCard test. They pass today, so three HoverCard cases would back the claim.

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

Not ready yet: two engineering-owner decisions and four fixes remain. An engineering owner needs to approve or reject the sentence this pull request adds to component:Tooltip FR9 (a plain onClick element around an anchorRef or useTooltip trigger receives the pinning press, where current FR9 says the press never reaches a row or container around the trigger), and to decide whether @astryxdesign/core should publish HoverCardPressTrigger and TooltipPressTrigger, which no current record names; any engineering owner, the author included, can record approval by commenting /approve-spec <full head SHA>.

  • Land #9232 and #9361 first and rebase, so this pull request holds only the HoverCard change instead of 2,710 authored lines.
  • Both changesets say the press stops at the trigger for useHoverCard and useTooltip too, but a plain onClick row around a bare hook trigger still activates; scope that sentence to the components.
  • A controlled labelled HoverCard announces its label as soon as a press asks it to open, even when the owner keeps it closed; announce only once it pins, and test the declined case.
  • Add HoverCard stop cases inside a ClickableCard, an Item row and a <label>, which its verification row now claims.

[Automated review]

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

[feat] HoverCard (and `useHoverCard`) take `pressTrigger` (type `HoverCardPressTrigger`): `none` (the default, unchanged) or `toggle`. With `toggle` on a button trigger, a click, a tap, Enter, or Space pins the card open and the same press closes it, while hover and focus still preview it. A pinned card stays until Escape, a second press, a press outside, or focus leaving; a press on its own content keeps it, 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. The trigger reports `aria-expanded` and `aria-controls`, and the card's `label` (else its text) is announced once when it pins, inside a modal too (`component:HoverCard` FR9 and FR10). On a trigger that is not a button, a labelled card keeps its own popup state and 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.

"The press stops at its trigger, so a clickable row, card, or label around it does nothing" holds for the HoverCard component. With the bare useHoverCard hook a plain onClick row still receives the press (as useHoverCard.doc.mjs says). Suggest scoping this sentence to the component and saying what a hook caller does.

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.

Same for useTooltip: a plain onClick row around a bare hook trigger still gets the pinning press; only the Tooltip component stops it at a child trigger.

Comment thread packages/core/src/Layer/usePressPin.ts Outdated
if (current.isOpen !== undefined) {
if (!current.isOpen) {
armOutsideDismiss();
announceName();

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 a controlled layer this announces the label before the owner answers onOpenChange(true). If the owner keeps isOpen={false}, a screen-reader user hears the card's name while nothing opens and the trigger says aria-expanded="false". FR10 announces it "when the card pins"; consider announcing once the controlled card shows pinned, with a test where the owner declines.

| 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 added sentence ("With anchorRef, or useTooltip with a caller's trigger, the caller's own handlers still receive the press ...") relaxes current FR9, which says the press "does not reach a clickable row, card, or container around it". That is a requirement change, so it needs an engineering owner's approval (/approve-spec <full head SHA>), or the anchored Tooltip has to stop the press as FR9 says today.

| FR3, AR1 | `HoverCard.test.tsx` role and trigger-attribute tests | Labelled and unlabelled; supported and unsupported roles | Wrong role, or trigger attributes that are not replaced and restored as stated, fail. | `audit:HoverCard/accessibility` |
| FR4–FR6, AR2 | `HoverCard.test.tsx` hover, Escape, refocus, and touch tests; `useTouchTrigger.test.ts` and `touchTriggerTargets.test.tsx` disabled-control cases; tap-destination cases an evidence gap until built | Hover, focus, tap, Escape from trigger and content; a trigger inside a link or a clickable card; a disabled control inside a clickable row | A card that cannot be reached or dismissed, or that opens on a tap that already acts, fails. | `audit:HoverCard/behavior` |
| FR7 | `HoverCard.test.tsx` isEnabled, isDefaultOpen, and onOpenChange tests; `layerDismissalFamilies.test.tsx` controlled HoverCard case | Disabled, default open | Wrong state reporting fails. | `audit:HoverCard/behavior` |
| FR9, FR10, AR3 | `usePressPin.test.tsx` HoverCard suites (click, Enter, Space, and tap pin; second press, press outside, and focus leaving close; pointer leave and presses on the card keep the pin; labelled and unlabelled announcements; a non-button trigger) and stop-at-trigger cases; `layerDismissalFamilies.test.tsx` pinned HoverCard over a Dialog, uncontrolled and controlled, closed by Escape | Click, Enter, Space, and tap pin; second press, press outside, focus leaving, and Escape close; pointer leave and presses on the card keep the pin; labelled and unlabelled; non-button trigger; a toggle trigger inside a ClickableCard, an Item row, and a `<label>` | A press that does not pin or close as stated, a pin lost on pointer leave, a missing or stale `aria-expanded` or `aria-controls`, a second announcement, a non-button trigger without the warning or its tap fallback, or a pinning press that also activates the card, row, or labelled control around the trigger, fails. | `audit:HoverCard/behavior` |

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 "stop-at-trigger cases" in usePressPin.test.tsx render Tooltip only; this row's ClickableCard, Item row and <label> states have no HoverCard test. They pass today, so three HoverCard cases would back the claim.

@vjeux
vjeux force-pushed the feat/hover-card-press-trigger branch from c6b017e to 26c8977 Compare November 2, 2026 00:48
@vjeux vjeux changed the title feat(HoverCard): pressTrigger="toggle" pins the card on a press feat(HoverCard): triggerBehavior="toggle" pins the card on a press 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.

Not ready yet: two engineering-owner decisions and four fixes remain. An engineering owner needs to approve or reject the sentence this pull request adds to component:Tooltip FR9 (a plain onClick element around an anchorRef or useTooltip trigger receives the pinning press, where current FR9 says the press never reaches a row or container around the trigger), and to decide whether @astryxdesign/core should publish HoverCardTriggerBehavior and TooltipTriggerBehavior, which no current record names; any engineering owner, the author included, can record approval by commenting /approve-spec <full head SHA>.

  • Land #9232 and #9361 first and rebase on main (this branch now conflicts there), so this pull request holds only the HoverCard change instead of 3,049 authored lines.
  • A controlled labelled HoverCard announces its label as soon as a press asks it to open, even when the owner keeps it closed; announce only once it pins, and test the declined case.
  • The HoverCard changeset says the press stops at the trigger for useHoverCard too, but a plain onClick row around a bare hook trigger still activates; scope it to the component, and update the API table in the description to 'adaptive' | 'hover' | 'toggle' with the Tooltip rows.
  • Add HoverCard stop cases inside a ClickableCard, an Item row and a <label>, which its verification row now cites as covered.

[Automated review]

Comment thread packages/core/src/Layer/usePressPin.ts Outdated
if (current.isOpen !== undefined) {
if (!current.isOpen) {
armOutsideDismiss();
announceName();

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 a controlled layer this announces the label before the owner answers onOpenChange(true). If the owner keeps isOpen={false}, a screen-reader user hears the label while nothing opens and the trigger says aria-expanded="false". HoverCard FR10 announces "when the card pins"; consider announcing a controlled card's label once it shows pinned, and adding a declined-owner case.

'@astryxdesign/core': patch
---

[feat] HoverCard (and `useHoverCard`) take `triggerBehavior` (type `HoverCardTriggerBehavior`): `adaptive`, the default and the released behavior, where hover and focus preview the card and a tap opens it unless the trigger performs an action of its own; `hover`, where hover and focus preview it and touch never 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 card stays until Escape, a second press, a press outside, or focus leaving; a press on its own content keeps it, 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. The trigger reports `aria-expanded` and `aria-controls`, and the card's `label` (else its text) is announced once when it pins, inside a modal too (`component:HoverCard` FR9 and FR10). On a trigger that is not a button, a labelled card keeps its own popup state and 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.

"The press stops at its trigger, so a clickable row, card, or label around it does nothing" holds for the HoverCard component. With the bare useHoverCard hook, a plain onClick row around the trigger still activates (as useHoverCard.doc.mjs says). The Tooltip changeset scopes this; the same wording would fit here.

| FR3, AR1 | `HoverCard.test.tsx` role and trigger-attribute tests | Labelled and unlabelled; supported and unsupported roles | Wrong role, or trigger attributes that are not replaced and restored as stated, fail. | `audit:HoverCard/accessibility` |
| FR4–FR6, AR2 | `HoverCard.test.tsx` hover, Escape, refocus, and touch tests; `useTouchTrigger.test.ts` and `touchTriggerTargets.test.tsx` disabled-control cases; tap-destination cases an evidence gap until built | Hover, focus, tap, Escape from trigger and content; a trigger inside a link or a clickable card; a disabled control inside a clickable row | A card that cannot be reached or dismissed, or that opens on a tap that already acts, fails. | `audit:HoverCard/behavior` |
| FR7 | `HoverCard.test.tsx` isEnabled, isDefaultOpen, and onOpenChange tests; `layerDismissalFamilies.test.tsx` controlled HoverCard case | Disabled, default open | Wrong state reporting fails. | `audit:HoverCard/behavior` |
| FR9, FR10, AR3 | `usePressPin.test.tsx` HoverCard suites (click, Enter, Space, and tap pin; second press, press outside, and focus leaving close; pointer leave and presses on the card keep the pin; labelled and unlabelled announcements; a non-button trigger) and stop-at-trigger cases; `layerDismissalFamilies.test.tsx` pinned HoverCard over a Dialog, uncontrolled and controlled, closed by Escape | Click, Enter, Space, and tap pin; second press, press outside, focus leaving, and Escape close; pointer leave and presses on the card keep the pin; labelled and unlabelled; non-button trigger; a toggle trigger inside a ClickableCard, an Item row, and a `<label>` | A press that does not pin or close as stated, a pin lost on pointer leave, a missing or stale `aria-expanded` or `aria-controls`, a second announcement, a non-button trigger without the warning or its tap fallback, or a pinning press that also activates the card, row, or labelled control around the trigger, fails. | `audit:HoverCard/behavior` |

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 "stop-at-trigger cases" in usePressPin.test.tsx render Tooltip only; this row's ClickableCard, Item row and <label> states have no HoverCard test. Three HoverCard cases beside the existing plain-row one would back the row.

| 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 added sentence ("With anchorRef, or useTooltip with a caller's trigger, the caller's own handlers still receive the press ...") relaxes current FR9, which says a pinning press does not reach a clickable row, card, or container around the trigger. That is a requirement change, so it needs an engineering owner's /approve-spec on this head, or the anchored Tooltip stops the press as FR9 says today.

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

Not ready yet: three engineering-owner decisions and three fixes remain. An engineering owner needs to approve or reject the sentences this pull request adds to component:Tooltip FR9 and component:HoverCard FR9 (a plain onClick element around an anchorRef, useTooltip or useHoverCard trigger receives the pinning press, where current FR9 says the press never reaches a row or container around the trigger), and to decide whether @astryxdesign/core should publish HoverCardTriggerBehavior and TooltipTriggerBehavior, which no current record names; any engineering owner, the author included, can record approval by commenting /approve-spec <full head SHA>.

  • Land #9232, #9406 and #9361 first and rebase, so this pull request holds only the HoverCard change instead of 3,197 authored lines.
  • A controlled labelled HoverCard announces its label as soon as a press asks it to open, even when the owner keeps it closed; announce only once it pins, and test the declined case.
  • Add HoverCard stop cases inside a ClickableCard, an Item row and a <label>, which its verification row cites, and update the description's API table to 'adaptive' | 'hover' | 'toggle', default 'adaptive', with the Tooltip rows.

[Automated review]

Comment thread packages/core/src/Layer/usePressPin.ts Outdated
if (current.isOpen !== undefined) {
if (!current.isOpen) {
armOutsideDismiss();
announceName();

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 a controlled layer this says the label before the owner answers onOpenChange(true). If the owner keeps isOpen={false}, a screen-reader user hears the label while nothing opens and the trigger says aria-expanded="false". Announce a controlled card's label only once it shows pinned, and add a declined-owner case.

| FR6 | Escape closes a visible card through the shared dismissal stack when it is the topmost layer in the page, so a layer underneath stays open. Implementation gap: a card 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). When focus was inside the card, it returns to the trigger, and that refocus does not reopen the card. | WCAG 1.4.13; tests |
| FR7 | `isOpen` forces the card shown or hidden, and `isOpen={true}` suppresses hover and focus hiding; a controlled card answers Escape by calling `onOpenChange(false)` without hiding, and setting `isOpen={false}` while focus is inside the card returns focus to the trigger. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, focus on the trigger still opens the card, and Escape then only reports `onOpenChange(false)` (Current-state impact). `isEnabled={false}` disables the triggers. `onOpenChange` reports each show and hide. | Current source and tests |
| FR8 | Content renders only while open; server markup and the first client render match, including a default-open card. `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 card open, and the same press on a pinned card closes it. Hover and focus still preview it per FR4; on touch no preview opens and a tap pins it, while a touch that becomes a scroll pins nothing. A pinned card stays open when the pointer leaves the trigger and the card, and a press on its own content keeps it pinned; Escape (FR6), a second press on the trigger, a press outside the trigger and the card, or focus moving outside them closes it. In a controlled card 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 `useHoverCard` and a caller's trigger, the caller's own handlers still receive the press: the trigger's `onClick` runs, and a plain `onClick` element around the trigger receives it unless the trigger'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 card, and no press pins it. | 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 added useHoverCard sentence relaxes current FR9 ("does not reach a clickable row, card, or container around it"), which the Public contract applies to the hook too. That is a requirement change, so it needs an engineering owner's approval (/approve-spec <full head SHA>), or the hook should stop the press as FR9 says today.

| 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 added sentence ("With anchorRef, or useTooltip with a caller's trigger, the caller's own handlers still receive the press ...") relaxes current FR9, which says a pinning press does not reach a row or container around the trigger. It needs an engineering owner's approval (/approve-spec <full head SHA>), or the anchored and hook paths should stop the press.

| FR3, AR1 | `HoverCard.test.tsx` role and trigger-attribute tests | Labelled and unlabelled; supported and unsupported roles | Wrong role, or trigger attributes that are not replaced and restored as stated, fail. | `audit:HoverCard/accessibility` |
| FR4–FR6, AR2 | `HoverCard.test.tsx` hover, Escape, refocus, and touch tests; `useTouchTrigger.test.ts` and `touchTriggerTargets.test.tsx` disabled-control cases; tap-destination cases an evidence gap until built | Hover, focus, tap, Escape from trigger and content; a trigger inside a link or a clickable card; a disabled control inside a clickable row | A card that cannot be reached or dismissed, or that opens on a tap that already acts, fails. | `audit:HoverCard/behavior` |
| FR7 | `HoverCard.test.tsx` isEnabled, isDefaultOpen, and onOpenChange tests; `layerDismissalFamilies.test.tsx` controlled HoverCard case | Disabled, default open | Wrong state reporting fails. | `audit:HoverCard/behavior` |
| FR9, FR10, AR3 | `usePressPin.test.tsx` HoverCard suites (click, Enter, Space, and tap pin; second press, press outside, and focus leaving close; pointer leave and presses on the card keep the pin; labelled and unlabelled announcements; a non-button trigger) and stop-at-trigger cases; `layerDismissalFamilies.test.tsx` pinned HoverCard over a Dialog, uncontrolled and controlled, closed by Escape | Click, Enter, Space, and tap pin; second press, press outside, focus leaving, and Escape close; pointer leave and presses on the card keep the pin; labelled and unlabelled; non-button trigger; a toggle trigger inside a ClickableCard, an Item row, and a `<label>` | A press that does not pin or close as stated, a pin lost on pointer leave, a missing or stale `aria-expanded` or `aria-controls`, a second announcement, a non-button trigger without the warning or its tap fallback, or a pinning press that also activates the card, row, or labelled control around the trigger, fails. | `audit:HoverCard/behavior` |

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 "stop-at-trigger cases" in usePressPin.test.tsx render Tooltip; this row's ClickableCard, Item row and <label> states have no HoverCard test. Three HoverCard cases beside the existing plain-row one would close the gap.

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

Not ready yet: three engineering-owner decisions and three fixes remain. An engineering owner needs to approve or reject the sentences this pull request adds to component:HoverCard FR9 and component:Tooltip FR9 (a plain onClick element around a useHoverCard, useTooltip or anchorRef trigger still receives the pinning press, where current FR9 says the press stops at the trigger), and decide whether @astryxdesign/core should export HoverCardTriggerBehavior and TooltipTriggerBehavior; any engineering owner, the author included, records an approval by commenting /approve-spec <full head SHA>. Whatever they decide, please:

  • Land #9232, #9406 and #9361 first and rebase, so this diff is the HoverCard change alone.
  • Announce a controlled labelled card only once it pins, since today its label is said even when the owner keeps isOpen={false}.
  • Add HoverCard tests for a toggle trigger inside a ClickableCard, an Item row and a <label>, which the verification row requires, and correct the API table in the description.

[Automated review]

Comment on lines +333 to +340
if (current.isOpen !== undefined) {
if (!current.isOpen) {
armOutsideDismiss();
announceName();
} else {
clearTapOpen();
}
current.report(!current.isOpen);

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 a controlled layer this says the label before the owner answers onOpenChange(true). If the owner keeps isOpen={false}, a screen-reader user hears "Ada's profile" while nothing opens and the trigger says aria-expanded="false". Announce a controlled labelled card only once it shows pinned (isPinShown), and add a declined-owner case beside the accepting one.

| FR6 | Escape closes a visible card through the shared dismissal stack when it is the topmost layer in the page, so a layer underneath stays open. Implementation gap: a card 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). When focus was inside the card, it returns to the trigger, and that refocus does not reopen the card. | WCAG 1.4.13; tests |
| FR7 | `isOpen` forces the card shown or hidden, and `isOpen={true}` suppresses hover and focus hiding; a controlled card answers Escape by calling `onOpenChange(false)` without hiding, and setting `isOpen={false}` while focus is inside the card returns focus to the trigger. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, focus on the trigger still opens the card, and Escape then only reports `onOpenChange(false)` (Current-state impact). `isEnabled={false}` disables the triggers. `onOpenChange` reports each show and hide. | Current source and tests |
| FR8 | Content renders only while open; server markup and the first client render match, including a default-open card. `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 card open, and the same press on a pinned card closes it. Hover and focus still preview it per FR4; on touch no preview opens and a tap pins it, while a touch that becomes a scroll pins nothing. A pinned card stays open when the pointer leaves the trigger and the card, and a press on its own content keeps it pinned; Escape (FR6), a second press on the trigger, a press outside the trigger and the card, or focus moving outside them closes it. In a controlled card 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 `useHoverCard` and a caller's trigger, the caller's own handlers still receive the press: the trigger's `onClick` runs, and a plain `onClick` element around the trigger receives it unless the trigger'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 card, and no press pins it. | 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 added useHoverCard sentence relaxes current FR9 ("does not reach a clickable row, card, or container around it"), which the Public contract applies to the hook too. It needs an engineering owner's /approve-spec, or useHoverCard should stop the press as FR9 says today.

| FR3, AR1 | `HoverCard.test.tsx` role and trigger-attribute tests | Labelled and unlabelled; supported and unsupported roles | Wrong role, or trigger attributes that are not replaced and restored as stated, fail. | `audit:HoverCard/accessibility` |
| FR4–FR6, AR2 | `HoverCard.test.tsx` hover, Escape, refocus, and touch tests; `useTouchTrigger.test.ts` and `touchTriggerTargets.test.tsx` disabled-control cases; tap-destination cases an evidence gap until built | Hover, focus, tap, Escape from trigger and content; a trigger inside a link or a clickable card; a disabled control inside a clickable row | A card that cannot be reached or dismissed, or that opens on a tap that already acts, fails. | `audit:HoverCard/behavior` |
| FR7 | `HoverCard.test.tsx` isEnabled, isDefaultOpen, and onOpenChange tests; `layerDismissalFamilies.test.tsx` controlled HoverCard case | Disabled, default open | Wrong state reporting fails. | `audit:HoverCard/behavior` |
| FR9, FR10, AR3 | `usePressPin.test.tsx` HoverCard suites (click, Enter, Space, and tap pin; second press, press outside, and focus leaving close; pointer leave and presses on the card keep the pin; labelled and unlabelled announcements; a non-button trigger) and stop-at-trigger cases; `layerDismissalFamilies.test.tsx` pinned HoverCard over a Dialog, uncontrolled and controlled, closed by Escape | Click, Enter, Space, and tap pin; second press, press outside, focus leaving, and Escape close; pointer leave and presses on the card keep the pin; labelled and unlabelled; non-button trigger; a toggle trigger inside a ClickableCard, an Item row, and a `<label>` | A press that does not pin or close as stated, a pin lost on pointer leave, a missing or stale `aria-expanded` or `aria-controls`, a second announcement, a non-button trigger without the warning or its tap fallback, or a pinning press that also activates the card, row, or labelled control around the trigger, fails. | `audit:HoverCard/behavior` |

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 "stop-at-trigger cases" in usePressPin.test.tsx render Tooltip; this row's ClickableCard, Item row and <label> states have no HoverCard component test (the component has only a plain onClick row case). Three HoverCard cases would close it; the behaviour holds when tried.

@cixzhang

cixzhang commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 14035ef

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 2026
…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/hover-card-press-trigger branch from 14035ef to 8fa3613 Compare November 3, 2026 01:56
@vjeux

vjeux commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated in 8fa3613, restacked on #9361's ed6c6cf (on main, which now carries #9232 and #9406).

  • Closed union: HoverCardTriggerBehavior is now 'adaptive' | 'hover' | 'toggle', exported, and packages/core/api-report.md lists HoverCard's three new rows. The pull request's API table matches them.
  • Controlled labelled card: the label is said, and the outside dismissal armed, once the owner shows the card pinned. Nothing is said when the owner keeps it closed, and a later press outside reports nothing. A new case covers the declined owner.
  • Stop cases: HoverCard.test.tsx now covers a toggle press inside an Astryx ClickableCard, an Item row, and a <label>.
  • Non-button trigger: the HoverCard case asserts the development warning, and a new case shows that a click pins nothing and a tap still opens the card.
  • Records: HoverCard's system_specs adds spec:AST-086/FR12 and /FR14, and a path-applicability block links Layer/usePressPin.ts. FR9's text stays as approved.
  • Controlled own-text pin: its owner's answer arms the outside dismissal too, with a case.
  • Space: the HoverCard keyboard case presses Space down and up, as fix(Tooltip): Space on keyup and a press outside in another document, with triggerBehavior evidence #9406's keyup timing needs.

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

@github-actions github-actions Bot added needs:spec-owner-review Current knowledge records await owner approval and removed needs:design-review Affects visuals — Design should review labels Nov 3, 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.

Not ready yet: one engineering-owner decision and one fix remain.

The sentence this pull request adds to component:HoverCard FR9 (with useHoverCard and a caller's trigger, a plain onClick element around the trigger receives the pinning press) relaxes the current FR9 stop clause, and an engineering owner approved it only at an earlier head. Any engineering owner, the author included, records the decision for this head by commenting /approve-spec <full head SHA>, or rejects it so useHoverCard stops the press as FR9 says today. Whatever they decide, please fix:

  • In a controlled labelled card, a press the owner declines leaves the pending-announcement flag set (packages/core/src/Layer/usePressPin.ts:279), so the next time the owner opens the card the label is announced as if that press had pinned it; announce the label on the same shown-pinned transition the unlabelled text uses, and add a declined-then-opened case.

[Automated review]

Comment thread packages/core/src/Layer/usePressPin.ts Outdated
if (!current.isOpen) {
armOutsideDismiss();
announceName();
nameOnPinRef.current = true;

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.

When the owner declines this request and keeps isOpen={false}, nothing clears this flag while the card stays closed. The next time the owner opens the card for any reason, the Effect below says the label and arms the outside dismissal as if this press had pinned it, while an owner-opened card with no earlier press says nothing (and an unlabelled card says its text either way). Suggest announcing the label on the same shown-pinned transition the unlabelled text uses (isPinShown) and dropping the flag, or clearing it when the owner leaves the card closed, plus a declined-then-opened test.

| FR6 | Escape closes a visible card through the shared dismissal stack when it is the topmost layer in the page, so a layer underneath stays open. Implementation gap: a card 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). When focus was inside the card, it returns to the trigger, and that refocus does not reopen the card. | WCAG 1.4.13; tests |
| FR7 | `isOpen` forces the card shown or hidden, and `isOpen={true}` suppresses hover and focus hiding; a controlled card answers Escape by calling `onOpenChange(false)` without hiding, and setting `isOpen={false}` while focus is inside the card returns focus to the trigger. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, focus on the trigger still opens the card, and Escape then only reports `onOpenChange(false)` (Current-state impact). `isEnabled={false}` disables the triggers. `onOpenChange` reports each show and hide. | Current source and tests |
| FR8 | Content renders only while open; server markup and the first client render match, including a default-open card. `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 card open, and the same press on a pinned card closes it. Hover and focus still preview it per FR4; on touch no preview opens and a tap pins it, while a touch that becomes a scroll pins nothing. A pinned card stays open when the pointer leaves the trigger and the card, and a press on its own content keeps it pinned; Escape (FR6), a second press on the trigger, a press outside the trigger and the card, or focus moving outside them closes it. In a controlled card 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 `useHoverCard` and a caller's trigger, the caller's own handlers still receive the press: the trigger's `onClick` runs, and a plain `onClick` element around the trigger receives it unless the trigger'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 card, and no press pins it. | 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 added sentence ("With useHoverCard and a caller's trigger, the caller's own handlers still receive the press ...") relaxes current FR9 ("does not reach a clickable row, card, or container around it"). It was approved at an earlier head; approval binds to a head, so it needs an engineering owner's /approve-spec <full head SHA> here, or a rejection so useHoverCard stops the press.

| FR3, AR1 | `HoverCard.test.tsx` role, trigger-attribute, and attribute-restore tests; `HoverCardAudit` frames and the audit axe pass on `HoverCard / Open States` | Labelled and unlabelled; supported and unsupported roles | Wrong role, trigger attributes that are not replaced and restored as stated, or a new axe violation on an open card, fail. | `audit:HoverCard/accessibility` |
| FR4–FR6, AR2 | `HoverCard.test.tsx` hover, delay and hide-delay timing, trigger-to-card hold, Escape, refocus, and touch tests; `HoverCardAudit` hover-and-keyboard pass in Chromium; `useTouchTrigger.test.ts` and `touchTriggerTargets.test.tsx` disabled-control cases; tap-destination cases an evidence gap until built | Hover, focus, tap, Escape from trigger and content; a trigger inside a link or a clickable card; a disabled control inside a clickable row | A card that cannot be reached or dismissed, that opens before `delay` or closes before `hideDelay`, that closes while the pointer moves from the trigger into it, or that opens on a tap that already acts, fails. | `audit:HoverCard/behavior` |
| FR7 | `HoverCard.test.tsx` isEnabled, isDefaultOpen, onOpenChange, `isOpen` forcing, and controlled-close focus-return tests; `layerDismissalFamilies.test.tsx` controlled HoverCard case | Disabled, default open, held open, held closed, closed by the caller with focus inside | Wrong state reporting, a hover that hides a card held open or opens one held closed, or focus left inside a card the caller closes, fails. | `audit:HoverCard/behavior` |
| FR9, FR10, AR3 | `usePressPin.test.tsx` HoverCard suites (click, Enter, Space, and tap pin; second press, press outside, and focus leaving close; pointer leave and presses on the card keep the pin; labelled and unlabelled announcements; a non-button trigger) and stop-at-trigger cases; `layerDismissalFamilies.test.tsx` pinned HoverCard over a Dialog, uncontrolled and controlled, closed by Escape | Click, Enter, Space, and tap pin; second press, press outside, focus leaving, and Escape close; pointer leave and presses on the card keep the pin; labelled and unlabelled; non-button trigger; a toggle trigger inside a ClickableCard, an Item row, and a `<label>` | A press that does not pin or close as stated, a pin lost on pointer leave, a missing or stale `aria-expanded` or `aria-controls`, a second announcement, a non-button trigger without the warning or its tap fallback, or a pinning press that also activates the card, row, or labelled control around the trigger, fails. | `audit:HoverCard/behavior` |

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 ClickableCard, Item row and <label> stop cases for the HoverCard component live in HoverCard.test.tsx ("a HoverCard toggle press stops at its trigger"), not in usePressPin.test.tsx. Suggest citing them there.

Comment on lines +379 to +380
if (!ownsToggleState) {
// The press pin sets 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.

Non-blocking (comment style): this empty branch, and the one at line 391, can be inverted to if (ownsToggleState) { ... }, letting the comment above ownsToggleState carry the reason.

@vjeux
vjeux force-pushed the feat/hover-card-press-trigger branch from 8fa3613 to b5931d2 Compare November 3, 2026 03:10
@vjeux

vjeux commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated in b5931d2.

  • Declined press: the pending-announcement flag is gone. A controlled card arms its outside dismissal and says its label each time its owner shows it pinned, the same transition the unlabelled card's rendered text uses. A declined press says and arms nothing. A new case covers an owner-open with no press, a declined press, the next owner-open, and a press outside; it fails with the flag.
  • Verification row: FR9/FR10/AR3 now cites the HoverCard.test.tsx stop cases.
  • HoverCard.tsx: the two empty branches are now one if (ownsToggleState) block.
  • FR9's useHoverCard sentence: the text is unchanged. The decision is with the spec owners.

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

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

Not ready yet: one engineering-owner decision remains, and nothing else blocks.

The sentence this pull request adds to component:HoverCard FR9 (with useHoverCard and a caller's trigger, a plain onClick element around the trigger still receives the pinning press) relaxes the current FR9 stop clause, and its earlier approval was at a previous head. Any engineering owner, the author included, records the decision for this head by commenting /approve-spec <full head SHA>, or rejects it so useHoverCard stops the press as FR9 says today.

The declined-press announcement fix holds, with its new test. One optional comment suggestion is inline.

[Automated review]

| FR6 | Escape closes a visible card through the shared dismissal stack when it is the topmost layer in the page, so a layer underneath stays open. Implementation gap: a card 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). When focus was inside the card, it returns to the trigger, and that refocus does not reopen the card. | WCAG 1.4.13; tests |
| FR7 | `isOpen` forces the card shown or hidden, and `isOpen={true}` suppresses hover and focus hiding; a controlled card answers Escape by calling `onOpenChange(false)` without hiding, and setting `isOpen={false}` while focus is inside the card returns focus to the trigger. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, focus on the trigger still opens the card, and Escape then only reports `onOpenChange(false)` (Current-state impact). `isEnabled={false}` disables the triggers. `onOpenChange` reports each show and hide. | Current source and tests |
| FR8 | Content renders only while open; server markup and the first client render match, including a default-open card. `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 card open, and the same press on a pinned card closes it. Hover and focus still preview it per FR4; on touch no preview opens and a tap pins it, while a touch that becomes a scroll pins nothing. A pinned card stays open when the pointer leaves the trigger and the card, and a press on its own content keeps it pinned; Escape (FR6), a second press on the trigger, a press outside the trigger and the card, or focus moving outside them closes it. In a controlled card 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 `useHoverCard` and a caller's trigger, the caller's own handlers still receive the press: the trigger's `onClick` runs, and a plain `onClick` element around the trigger receives it unless the trigger'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 card, and no press pins it. | 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 added useHoverCard sentence relaxes current FR9 ("does not reach a clickable row, card, or container around it"). Its approval was at an earlier head and binds to a head, so it needs an engineering owner's /approve-spec <full head SHA> here, or a rejection so useHoverCard stops the press.

// interactive-ancestor walk, so a clickable container around the
// trigger leaves it alone; document listeners still see it.
ref={registerLayerSurface}
// The pin's announcement reads this element's 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 read is useHoverCard's own useAnnounceRenderedText call, not the press pin's. Suggest:

// An unlabelled pinned card's announcement reads this element's text.

`component:HoverCard` FR9, FR10 and AR3, on the shared press pin
(`Layer/usePressPin.ts`):

- `triggerBehavior` on HoverCard and useHoverCard, with the closed-union
  type HoverCardTriggerBehavior (exported): `adaptive`, the default and the released
  behavior (a tap opens the card unless the trigger acts; an explicit
  `touchTrigger` still decides taps under it until the next minor); `hover`
  (touch never opens it); or `toggle`. Hover and focus preview it under
  every value. With `toggle` on a button trigger, a click, a tap, Enter, or
  Space pins the card and the same press closes it.
- A pinned card stays until Escape, a second press, a press or scroll
  outside, or focus moving onto an element outside the trigger and the card
  (the pin listens for it on the trigger, whatever `focusTrigger` is); a
  press on its own content keeps it. It takes Escape before the layer
  beneath it, controlled or not. useHoverCard makes one usePressPin call,
  and a card whose `triggerBehavior` turns to `adaptive` while pinned closes on
  leave again.
- The press stops at its trigger. The trigger carries aria-expanded and
  aria-controls on a button trigger; on any other trigger a labelled card
  keeps its own (FR3). When a press pins a card with a `label`, the press
  handler says the label once through useAnnounce (a controlled card says it
  each time its owner shows it pinned, as an unlabelled card's text is
  said, and nothing for a press the owner declines); otherwise the card's
  rendered text is announced once through useAnnounceRenderedText.
- HoverCard.test.tsx: `adaptive` by default and explicitly, `hover`, and
  `toggle`, each under a mouse hover, focus, a tap, and a mouse click and a
  tap on a button trigger (which only the toggle pins), with `touchTrigger`
  beside each value (HoverCard FR5 and FR9's `triggerBehavior` row); and
  `useHoverCard` with a caller's trigger: its own onClick runs, an Astryx
  ClickableCard around it does not activate, and a plain onClick element
  around it receives the press unless the trigger's onClick stops it.
- HoverCard FR9 states that `useHoverCard` clause, as Tooltip FR9 does for
  `anchorRef` and `useTooltip`; the changeset scopes the stop at the trigger
  to the HoverCard component.
- HoverCard.test.tsx also stops a toggle press at its trigger inside an
  Astryx ClickableCard, an Item row, and a `<label>`. The HoverCard record
  links `Layer/usePressPin.ts` and `spec:AST-086` FR12 and FR14.
- The HoverCard Space test presses Space down and up, as meta#9406's keyup timing
  needs. The API report lists HoverCard's three new rows.
@vjeux
vjeux force-pushed the feat/hover-card-press-trigger branch from b5931d2 to bdde69a Compare November 3, 2026 04:25
@vjeux

vjeux commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated in bdde69a: the comment above the card's content now reads "An unlabelled pinned card's announcement reads this element's text.", as suggested. Nothing else changed.

FR9's useHoverCard sentence is with the spec owners. This head needs a spec owner's /approve-spec bdde69a7f1772326e38b56d034c6aa58ab0d7689.

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

Not ready to approve yet: one engineering-owner decision remains, and nothing else blocks.

  • The sentence this pull request adds to the HoverCard spec's FR9 lets a plain onClick element around a useHoverCard caller's trigger receive the pinning press, where FR9 today says that press never reaches a row, card or container around the trigger, and the earlier spec approval does not carry over to this head.

An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request (the author may, as an engineering owner), or rejects the sentence so useHoverCard stops the press as FR9 says today. The toggle itself matches the spec, and the earlier comment suggestion in useHoverCard.tsx is applied.

[Automated review]

@vjeux

vjeux commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #9756, which removed the pin/toggle path this built on. Thanks to humbertovirtudes for the review on #9361. Any 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/hover-card-press-trigger branch November 4, 2026 02:41

This branch was successfully deployed

1 active deployment
Preview — bdde69a7 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