Repository navigation
feat(Tooltip): triggerBehavior="toggle" pins the tooltip on a press - #9232
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| LayerProvider | 62.5 kB (+1.8 kB) · 10.5 kB CSS (0) | — | ✓ · ✓ · ✗ |
| lab/Schedule | 🔴 61.1 kB (+3.3 kB) · 3.9 kB CSS (0) | — | — · — · — |
| Carousel | 🔴 50.5 kB (+3.2 kB) · 10.5 kB CSS (0) | — | — · — · — |
116 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Popover | 🔴 49.6 kB (+3.2 kB) · 12.4 kB CSS (0) | — | — · — · — |
| lab/TourStep | 🔴 55.0 kB (+3.2 kB) · 590 B CSS (0) | — | — · — · — |
| TableSelectionToolbar | 🔴 52.0 kB (+2.7 kB) · 11.5 kB CSS (0) | — | — · — · — |
| DrawerHeader | 🔴 48.3 kB (+2.7 kB) · 11.6 kB CSS (0) | — | — · — · — |
| DialogHeader | 🔴 48.2 kB (+2.6 kB) · 10.2 kB CSS (0) | — | — · — · — |
| lab/InfoTip | 🔴 26.0 kB (+2.6 kB) · 458 B CSS (0) | — | — · — · — |
| Tooltip · Storybook | 🔴 20.8 kB (+2.6 kB) · 5.0 kB CSS (0) | 644 (+40) | ✓ · ✓ · ✓ |
| StatusDot | 🔴 23.0 kB (+2.6 kB) · 6.3 kB CSS (0) | — | — · — · — |
| ChatLayout | 🔴 48.3 kB (+2.6 kB) · 10.3 kB CSS (0) | — | — · — · — |
| Stepper | 🔴 46.8 kB (+2.6 kB) · 9.9 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 🔴 70.5 kB (+2.6 kB) · 2.1 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 🔴 45.8 kB (+2.6 kB) · 9.8 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 🔴 45.6 kB (+2.6 kB) · 9.7 kB CSS (0) | — | — · — · — |
| FieldLabel | 🔴 35.9 kB (+2.6 kB) · 5.9 kB CSS (0) | — | — · — · — |
| ToggleButton | 🔴 43.1 kB (+2.5 kB) · 9.6 kB CSS (0) | — | — · — · — |
| TopNavMenu | 🔴 57.9 kB (+2.5 kB) · 10.5 kB CSS (0) | — | — · — · — |
| ChatSendButton | 🔴 45.0 kB (+2.5 kB) · 9.5 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 🔴 54.0 kB (+2.5 kB) · 11.2 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 🔴 45.9 kB (+2.5 kB) · 9.8 kB CSS (0) | — | — · — · — |
| IconButton | 🔴 42.2 kB (+2.5 kB) · 9.5 kB CSS (0) | — | — · — · — |
| Banner | 🔴 47.1 kB (+2.5 kB) · 10.3 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 🔴 45.6 kB (+2.5 kB) · 9.9 kB CSS (0) | — | — · — · — |
| Button | 🔴 42.1 kB (+2.5 kB) · 9.5 kB CSS (0) | — | — · — · — |
| Toast | 🔴 59.2 kB (+2.5 kB) · 10.1 kB CSS (0) | — | — · — · — |
| TabMenu | 🔴 55.0 kB (+2.5 kB) · 10.4 kB CSS (0) | — | — · — · — |
| Link | 🔴 42.7 kB (+2.5 kB) · 7.9 kB CSS (0) | — | — · — · — |
| TopNavHeading | 🔴 57.8 kB (+2.5 kB) · 10.4 kB CSS (0) | — | — · — · — |
| lab/CommentPin | 🔴 46.9 kB (+2.4 kB) · 1.2 kB CSS (0) | — | — · — · — |
| SideNavHeading | 🔴 58.4 kB (+2.4 kB) · 10.5 kB CSS (0) | — | — · — · — |
| SideNavItem | 🔴 54.3 kB (+2.4 kB) · 10.4 kB CSS (0) | — | — · — · — |
| Avatar | 🔴 34.9 kB (+2.4 kB) · 6.5 kB CSS (0) | — | — · — · — |
| SegmentedControl | 🔴 36.6 kB (+2.4 kB) · 6.5 kB CSS (0) | — | — · — · — |
| AvatarGroupOverflow | 🔴 38.7 kB (+2.4 kB) · 6.5 kB CSS (0) | — | — · — · — |
| AvatarGroup | 🔴 37.5 kB (+2.4 kB) · 6.6 kB CSS (0) | — | — · — · — |
| AppShell | 🔴 68.1 kB (+2.3 kB) · 12.1 kB CSS (0) | — | — · — · — |
| AlertDialog | 🔴 55.9 kB (+2.1 kB) · 12.7 kB CSS (0) | — | — · — · — |
| SideNav | 🔴 65.5 kB (+2.1 kB) · 10.9 kB CSS (0) | — | — · — · — |
| TopNav | 🔴 51.6 kB (+2.1 kB) · 10.7 kB CSS (0) | — | — · — · — |
| MobileNav | 50.0 kB (+2.0 kB) · 10.4 kB CSS (0) | — | — · — · — |
| Lightbox | 50.2 kB (+2.0 kB) · 10.1 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 55.7 kB (+1.9 kB) · 10.4 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 55.7 kB (+1.9 kB) · 10.4 kB CSS (0) | — | — · — · — |
| TimeInput | 88.4 kB (+1.9 kB) · 14.3 kB CSS (0) | — | — · — · — |
| CodeBlock | 58.9 kB (+1.9 kB) · 11.1 kB CSS (0) | — | — · — · — |
| Calendar | 54.1 kB (+1.9 kB) · 10.3 kB CSS (0) | — | — · — · — |
| DateInput | 101.0 kB (+1.8 kB) · 15.3 kB CSS (0) | — | — · — · — |
| charts/ChartTooltip | 52.1 kB (+1.8 kB) · 20 B CSS (0) | — | — · — · — |
| DateTimeInput | 113.0 kB (+1.8 kB) · 15.8 kB CSS (0) | — | — · — · — |
| Thumbnail | 49.3 kB (+1.8 kB) · 11.3 kB CSS (0) | — | — · — · — |
| TableCell | 76.0 kB (+1.8 kB) · 15.8 kB CSS (0) | — | — · — · — |
| charts/ChartLegend | 52.2 kB (+1.8 kB) · 20 B CSS (0) | — | — · — · — |
| Drawer | 36.1 kB (+1.8 kB) · 8.2 kB CSS (0) | — | — · — · — |
| ContextMenu | 74.8 kB (+1.8 kB) · 15.3 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 64.7 kB (+1.8 kB) · 773 B CSS (0) | — | — · — · — |
| charts/Chart | 62.6 kB (+1.8 kB) · 20 B CSS (0) | — | — · — · — |
| DropdownMenu | 72.6 kB (+1.8 kB) · 15.4 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 65.2 kB (+1.8 kB) · 1.1 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 256.6 kB (+1.7 kB) · 2.3 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 66.7 kB (+1.7 kB) · 11.4 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 75.6 kB (+1.7 kB) · 15.5 kB CSS (0) | — | — · — · — |
| MoreMenu | 72.8 kB (+1.7 kB) · 15.4 kB CSS (0) | — | — · — · — |
| DateRangeInput | 69.4 kB (+1.7 kB) · 11.7 kB CSS (0) | — | — · — · — |
| FileInput | 53.5 kB (+1.7 kB) · 10.7 kB CSS (0) | — | — · — · — |
| ComplexSelector | 55.2 kB (+1.7 kB) · 11.1 kB CSS (0) | — | — · — · — |
| TextInput | 52.7 kB (+1.7 kB) · 10.9 kB CSS (0) | — | — · — · — |
| Switch | 47.0 kB (+1.7 kB) · 9.7 kB CSS (0) | — | — · — · — |
| CheckboxList | 43.2 kB (+1.7 kB) · 8.6 kB CSS (0) | — | — · — · — |
| TextArea | 47.1 kB (+1.7 kB) · 9.8 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 80.4 kB (+1.7 kB) · 1.9 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 70.0 kB (+1.7 kB) · 722 B CSS (0) | — | — · — · — |
| Field | 41.3 kB (+1.7 kB) · 8.3 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 276.0 kB (+1.7 kB) · 2.6 kB CSS (0) | — | — · — · — |
| InputGroup | 41.9 kB (+1.7 kB) · 8.4 kB CSS (0) | — | — · — · — |
| NumberInput | 54.8 kB (+1.7 kB) · 11.2 kB CSS (0) | — | — · — · — |
| lab/TransferList | 74.2 kB (+1.7 kB) · 1.7 kB CSS (0) | — | — · — · — |
| RadioList | 42.8 kB (+1.7 kB) · 8.3 kB CSS (0) | — | — · — · — |
| CheckboxInput | 48.6 kB (+1.7 kB) · 9.7 kB CSS (0) | — | — · — · — |
| RadioListItem | 51.1 kB (+1.7 kB) · 10.1 kB CSS (0) | — | — · — · — |
| Slider | 46.1 kB (+1.6 kB) · 8.9 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 53.2 kB (+1.6 kB) · 11.0 kB CSS (0) | — | — · — · — |
| ListItem | 52.5 kB (+1.6 kB) · 11.0 kB CSS (0) | — | — · — · — |
| lab/MobilePowerSearch | 166.5 kB (+1.5 kB) · 1.2 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 221.2 kB (+1.5 kB) · 454 B CSS (0) | — | — · — · — |
| lab/MobileTokenizer | 100.6 kB (+1.4 kB) · 880 B CSS (0) | — | — · — · — |
| ChatComposer | 60.6 kB (+1.4 kB) · 11.2 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 101.9 kB (+1.4 kB) · 1.9 kB CSS (0) | — | — · — · — |
| lab/Comments | 231.7 kB (+1.4 kB) · 2.5 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 54.6 kB (+1.3 kB) · 10.2 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 226.3 kB (+1.3 kB) · 2.4 kB CSS (0) | — | — · — · — |
| Tokenizer | 69.6 kB (+1.3 kB) · 17.1 kB CSS (0) | — | — · — · — |
| lab/ListInput | 81.3 kB (+1.3 kB) · 1.6 kB CSS (0) | — | — · — · — |
| PowerSearch | 182.3 kB (+1.3 kB) · 20.5 kB CSS (0) | — | — · — · — |
| MultiSelector | 72.2 kB (+1.3 kB) · 15.2 kB CSS (0) | — | — · — · — |
| Selector | 76.4 kB (+1.3 kB) · 15.6 kB CSS (0) | — | — · — · — |
| Markdown | 144.9 kB (+1.2 kB) · 18.3 kB CSS (0) | — | — · — · — |
| Typeahead | 62.2 kB (+1.2 kB) · 11.8 kB CSS (0) | — | — · — · — |
| Pagination | 85.3 kB (+1.2 kB) · 15.9 kB CSS (0) | — | — · — · — |
| Table | 84.1 kB (+1.2 kB) · 16.0 kB CSS (0) | — | — · — · — |
| CommandPalette | 48.4 kB (+180 B) · 12.2 kB CSS (0) | — | — · — · — |
| ProgressBar | 8.1 kB (+130 B) · 6.9 kB CSS (0) | — | — · — · — |
| ChatMessageList | 22.8 kB (+97 B) · 7.9 kB CSS (0) | — | — · — · — |
| CommandPaletteInput | 26.7 kB (+81 B) · 8.5 kB CSS (0) | — | — · — · — |
| HoverCard | 18.5 kB (+54 B) · 5.0 kB CSS (0) | — | — · — · — |
| Spinner | 18.5 kB (+41 B) · 6.7 kB CSS (0) | — | — · — · — |
| Timestamp | 21.3 kB (+37 B) · 9.9 kB CSS (0) | — | — · — · — |
| Timer | 9.6 kB (+35 B) · 7.0 kB CSS (0) | — | — · — · — |
| ChatToolCalls | 25.8 kB (+32 B) · 9.3 kB CSS (0) | — | — · — · — |
| Heading | 7.9 kB (+19 B) · 6.0 kB CSS (0) | — | — · — · — |
| Text | 7.4 kB (+14 B) · 6.0 kB CSS (0) | — | — · — · — |
| BottomSheet | 35.0 kB (0) · 7.5 kB CSS (0) | — | — · — · — |
| Dialog | 16.6 kB (0) · 6.6 kB CSS (0) | — | — · — · — |
| TabList | 35.4 kB (0) · 7.5 kB CSS (0) | — | — · — · — |
| Toolbar | 34.7 kB (0) · 7.9 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 55.9 kB (−26 B) · 9.9 kB CSS (0) | — | — · — · — |
| layer | — | — | — · ✓ · — |
| Layer | — | — | ✓ · ✓ · — |
Package size: @astryxdesign/core 5.83 MB packed (+12.0 kB); no new dependencies.
API changes: core +4 · ~0 · −0
Committed API report behind this build: core 18 rows; run pnpm api:report.
4 API changes (advisory)
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | core |
. · Components · component Tooltip |
prop triggerBehavior?: TooltipTriggerBehavior = 'adaptive' |
<Tooltip triggerBehavior="adaptive" /> |
| + | core |
. · Types · interface TooltipOptions |
triggerBehavior?: TooltipTriggerBehavior = 'adaptive' |
import type {TooltipOptions} from '@astryxdesign/core'; const x: TooltipOptions = {triggerBehavior: …} |
| + | core |
. · Types · type TooltipTriggerBehavior |
type TooltipTriggerBehavior = 'adaptive' | 'hover' | 'toggle' |
import type {TooltipTriggerBehavior} from '@astryxdesign/core' |
| + | core |
./Tooltip · Also exported from an earlier entry point · TooltipTriggerBehavior |
TooltipTriggerBehavior (.) |
import {TooltipTriggerBehavior} from '@astryxdesign/core/Tooltip' |
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Changes requested: the toggle behaves as component:Tooltip FR9 describes for button triggers, but a few gaps need fixing first.
- A pin inside a modal
Dialogis announced withannounceMessageinto the page-body live region, which the modal hides, so announce throughuseAnnounceoruseAnnounceRenderedTextto getspec:AST-086FR14 routing. - A labelled HoverCard on a non-button trigger loses
aria-controls/aria-expandedunderpressTrigger="toggle"(HoverCard.tsx:380), which also makes the codemod's span rewrite change behavior; hand that state to the pin only when it wires the trigger, and test it. - The outside-press Effect in
usePressPinduplicatesuseTouchTrigger's outside dismissal; please extend that owner instead. - The hook docs promise the press stops at the trigger (it does not without the component wrapper),
touchTrigger="tap"has no@deprecatedtag, andTooltipPressTrigger/HoverCardPressTriggerare missing from the entry-point exports. - At 2,307 authored lines, please split the DEP-0016 codemod and deprecation into a follow-up in the same release.
[Automated review]
| announcedRef.current = true; | ||
| const text = optionsRef.current.announcement()?.trim(); | ||
| if (text != null && text !== '') { | ||
| announceMessage(text, 'polite'); |
There was a problem hiding this comment.
announceMessage always writes to the page-body live region. Inside an open modal Dialog, that region is inert, so the pin is never heard; useAnnounce() routes to the modal's own region (spec:AST-086 FR14). The shared useAnnounceRenderedText already reads a layer's rendered text and announces it through useAnnounce, so gating it on the pin would replace this Effect.
|
|
||
| // Under the toggle, the press pin owns aria-expanded (true only while | ||
| // pinned) and aria-controls (FR10); the popup role stays here. | ||
| const ownsToggleState = pressTrigger !== 'toggle'; |
There was a problem hiding this comment.
This hands aria-controls/aria-expanded to the press pin for every trigger, but usePressPin wires only button triggers. A labelled HoverCard on a span or link trigger therefore loses HoverCard FR3's popup state, and the codemod rewrites such spans. Something like pressTrigger === 'toggle' && isPressPinTrigger(firstChild) keeps FR3 for the rest.
| // While pinned, a press or focus outside the trigger and the layer closes it. | ||
| useEffect(() => { | ||
| if (!isToggleMode || trigger == null || !isExpanded) { | ||
| return; | ||
| } | ||
| const ownerDocument = trigger.ownerDocument; | ||
| const isInside = (target: EventTarget | null) => { | ||
| if (!(target instanceof Node)) { | ||
| return false; | ||
| } | ||
| const surface = ownerDocument.getElementById(layerId); | ||
| return ( | ||
| trigger.contains(target) || | ||
| (surface != null && surface.contains(target)) | ||
| ); | ||
| }; | ||
| const onPointerDown = (event: PointerEvent) => { | ||
| if (!isInside(event.target)) { | ||
| close(); | ||
| } | ||
| }; | ||
| const onFocusIn = (event: FocusEvent) => { | ||
| if (!isInside(event.target)) { | ||
| close(); | ||
| } | ||
| }; | ||
| ownerDocument.addEventListener('pointerdown', onPointerDown, true); | ||
| ownerDocument.addEventListener('focusin', onFocusIn, true); | ||
| return () => { | ||
| ownerDocument.removeEventListener('pointerdown', onPointerDown, true); | ||
| ownerDocument.removeEventListener('focusin', onFocusIn, true); | ||
| }; | ||
| }, [isToggleMode, trigger, isExpanded, layerId, close]); |
There was a problem hiding this comment.
useTouchTrigger (armOutsideDismiss), which both hooks already call, owns outside dismissal for hover layers, armed from the opening handler. This Effect adds a second path with its own containment test. Could the pin arm that owner from toggle, and could focus leaving close a pinned layer through the existing focus-leave path?
| {name: 'focusTrigger', type: "'auto' | 'always' | 'never'", description: 'When focus should open the tooltip. auto only attaches focus listeners to naturally focusable elements.', default: "'auto'"}, | ||
| {name: 'touchTrigger', type: "'auto' | 'tap' | 'none'", description: 'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own; tap always opens (an info icon rendered as a button); none never opens on touch.', default: "'auto'"}, | ||
| {name: 'touchTrigger', type: "'auto' | 'tap' | 'none'", description: 'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own; tap always opens (deprecated, DEP-0016: use pressTrigger="toggle"); none never opens on touch. Ignored under pressTrigger="toggle".', default: "'auto'"}, | ||
| {name: 'pressTrigger', type: "'none' | 'toggle'", description: 'Whether a press on the trigger pins the tooltip open. none leaves taps to touchTrigger; toggle, on a button trigger, pins on a click, a tap, Enter, or Space and closes on the same press, Escape, a press outside, or focus leaving. The trigger carries aria-expanded and aria-controls, the tooltip is announced once when it pins, and the press stops at the trigger.', default: "'none'"}, |
There was a problem hiding this comment.
"The press stops at the trigger" holds only for the Tooltip/HoverCard components, whose wrapper calls stopPropagation. With the hook alone, a button inside <div onClick> pins the tooltip and also fires the row's handler. The same wording is in useHoverCard.doc.mjs and both hooks' JSDoc.
| * as a button wants: it looks like an action to the DOM, but revealing the | ||
| * tooltip is the only thing it does | ||
| * - `tap`: tap always opens the tooltip, even on a trigger that acts. | ||
| * Deprecated (DEP-0016): pass `pressTrigger="toggle"` instead; `astryx |
There was a problem hiding this comment.
This is prose only. DEP-0016's warning field and spec:AST-017 FR29a ask for static @deprecated metadata on tap, and the description says it is present, but no @deprecated tag exists for it.
| export type {TooltipFocusTrigger, TooltipTouchTrigger} from './useTooltip'; | ||
| export type { | ||
| TooltipFocusTrigger, | ||
| TooltipPressTrigger, |
There was a problem hiding this comment.
TooltipPressTrigger (and HoverCardPressTrigger) is not added to Tooltip/index.ts, HoverCard/index.ts or Layer/index.ts. Those files export the FocusTrigger/TouchTrigger siblings, so the new types are unreachable from @astryxdesign/core (architecture:public-component-api INV1).
a5250c6 to
c543d57
Compare
|
Per the owner's ruling, DEP-0016 (the |
There was a problem hiding this comment.
Changes requested: the toggle now pins and closes as component:Tooltip FR9 describes and the earlier findings are fixed, but a few gaps remain.
- In Chromium, a press on a pinned HoverCard's (or Tooltip's) own text closes it, because the focus-leave check treats focus moving to the page body as leaving (
usePressPin.ts:353-359), while HoverCard FR9 says such a press keeps the pin. - The pin reads
textContentand announces it from its own Effect, butarchitecture:react-component-runtimeINV10 puts that inuseAnnounceRenderedText, which also keeps an unlabelled card's paragraphs apart (today it says "Ada LovelaceAnalyst, Payments"). - The HoverCard verification row cites Enter, Space, press-outside, focus-leave, pointer-leave and unlabelled cases that no HoverCard test covers yet.
- Smaller: the
touchDismissRefbridge Effect and the trigger element kept in state inusePressPin, the duplicatedstopPressPinClick, and the changeset's forward-looking DEP-0016 sentence.
[Automated review]
| if ( | ||
| next instanceof Node && | ||
| (trigger?.contains(next) === true || surface?.contains(next) === true) | ||
| ) { | ||
| return true; | ||
| } | ||
| close(); |
There was a problem hiding this comment.
When the person presses non-focusable text inside the pinned layer, Chromium moves focus from the trigger to the body, so relatedTarget is null and this closes the pin. A pinned HoverCard then closes on a press on its own content, against HoverCard FR9 ("a press on its own content keeps it pinned"), and a pinned Tooltip closes the same way. Could a focus move caused by a press inside the trigger or the layer be left to useTouchTrigger's outside dismissal, with this closing only when focus lands outside both?
| useEffect(() => { | ||
| if (!isToggleMode || trigger == null || !isExpanded || !wiresState) { | ||
| announcedRef.current = false; | ||
| return; | ||
| } | ||
| if (announcedRef.current) { | ||
| return; | ||
| } | ||
| announcedRef.current = true; | ||
| const text = optionsRef.current.announcement()?.trim(); | ||
| if (text != null && text !== '') { | ||
| announce(text, 'polite'); | ||
| } | ||
| }, [isToggleMode, trigger, isExpanded, wiresState, announce]); |
There was a problem hiding this comment.
This Effect announces text the hosts read with textContent. architecture:react-component-runtime INV10 keeps reading and announcing a component's rendered text in hooks/useAnnounceRenderedText.ts, which skips aria-hidden content and keeps blocks apart; an unlabelled HoverCard with two paragraphs is announced here as "Ada LovelaceAnalyst, Payments".
| }, []); | ||
|
|
||
| // The wired trigger, as state: its ARIA follows the pin through effects. | ||
| const [trigger, setTrigger] = useState<HTMLElement | null>(null); |
There was a problem hiding this comment.
architecture:react-component-runtime INV1: DOM nodes must not be stored in React state. The trigger can live in triggerRef alone, with attach/detach setting and restoring its aria-expanded/aria-controls, which would also replace the restore Effect below.
| useEffect(() => { | ||
| touchDismissRef.current = {arm: armOutsideDismiss, disarm: clearTapOpen}; | ||
| }, [armOutsideDismiss, clearTapOpen]); |
There was a problem hiding this comment.
This Effect only copies useTouchTrigger's callbacks into a ref, so it synchronizes no external system (INV3), and the same bridge and hideFromTouch are copied in useHoverCard.tsx:450-452. Letting usePressPin own the touch-trigger wiring (or useTouchTrigger take the pin's close) would leave each hook one call.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [feat] Tooltip and HoverCard (and `useTooltip`, `useHoverCard`) take `pressTrigger` (types `TooltipPressTrigger`, `HoverCardPressTrigger`): `none` (the default, unchanged) or `toggle`. With `toggle` on a button trigger, a click, a tap, Enter, or Space pins the layer open and the same press closes it, while hover and focus still preview it. A pinned layer 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 layer is announced once when it pins, inside a modal too (`component:Tooltip` FR9 and FR10, `component:HoverCard` 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. `touchTrigger="tap"` is deprecated in favor of `pressTrigger="toggle"` in the next patch (DEP-0016). |
There was a problem hiding this comment.
The last sentence announces the DEP-0016 deprecation, which now ships in the stacked follow-up. Could it move to that follow-up's changeset so this release note describes only what this change does?
c543d57 to
90ae917
Compare
|
Fixed in 90ae917, per the spec owners' ruling:
Kept, per the spec owners' ruling: the changeset says |
There was a problem hiding this comment.
Changes requested: the toggle now behaves as component:Tooltip and component:HoverCard FR9 and FR10 describe, and the earlier findings are fixed, but three items remain.
- The touch-trigger bridge (
touchDismissRef,hideFromTouch, theusePressPincall and thetouchTriggeroverride) is copied line for line intouseTooltip.tsx:375-439anduseHoverCard.tsx:384-448; moving it intousePressPin, so each hook makes one call, keeps the two layers from drifting apart. - At 2,218 authored lines the change is over the 2,000-line threshold; the HoverCard wiring (about 600 lines) could land as a follow-up, or the description could show why the two are inseparable.
- The changeset's last sentence announces DEP-0016, which ships in #9246, so it belongs in that pull request's changeset.
[Automated review]
| // A press pins the card under `pressTrigger="toggle"` (FR9, FR10). The pin | ||
| // arms and drops the touch trigger's outside dismissal, the one owner of a | ||
| // hover layer's dismissal by a press outside. That hook takes the pin's | ||
| // close as part of its hide, so the pin reaches it through a ref, assigned | ||
| // during render below and read only from handlers. | ||
| const touchDismissRef = useRef<{arm: () => void; disarm: () => void} | null>( | ||
| null, | ||
| ); | ||
| const armTouchDismiss = useCallback(() => touchDismissRef.current?.arm(), []); | ||
| const disarmTouchDismiss = useCallback( | ||
| () => touchDismissRef.current?.disarm(), | ||
| [], | ||
| ); | ||
|
|
||
| const { | ||
| isToggleTrigger, | ||
| isPinnedRef: isPressPinnedRef, | ||
| attach: attachPressPin, | ||
| unpin: unpinPress, | ||
| closeIfPinned: closePressPin, | ||
| handleFocusLeave: handlePressFocusLeave, | ||
| isPinShown, | ||
| } = usePressPin({ | ||
| pressTrigger, | ||
| isEnabled, | ||
| isOpen, | ||
| isLayerOpen, | ||
| layerId, | ||
| component: 'HoverCard', | ||
| show: showNow, | ||
| hide: hideNow, | ||
| report: next => (next ? onShow?.() : onHide?.()), | ||
| label, | ||
| armOutsideDismiss: armTouchDismiss, | ||
| disarmOutsideDismiss: disarmTouchDismiss, | ||
| }); | ||
|
|
||
| // An outside press or scroll closes a pinned layer through the pin, so the | ||
| // pin drops with it; otherwise it hides as a tap-open does. | ||
| const hideFromTouch = useCallback(() => { | ||
| if (closePressPin()) { | ||
| return; | ||
| } | ||
| hideNow(); | ||
| }, [closePressPin, hideNow]); | ||
|
|
||
| const { | ||
| isTouchPointerRef, | ||
| isTouchInteraction, | ||
| handlePointerEnter, | ||
| handlePointerDown: handleTouchPointerDown, | ||
| clearTapOpen, | ||
| } = useTouchTrigger({ | ||
| touchTrigger, | ||
| armOutsideDismiss, | ||
| } = useTouchTriggerInternal({ | ||
| // Under the toggle, a trigger no press can pin keeps tap-only opening. | ||
| touchTrigger: pressTrigger === 'toggle' ? 'tap' : touchTrigger, | ||
| isEnabled, | ||
| isControlled: isOpen !== undefined, | ||
| isOpen: isLayerOpen, | ||
| layerId: layerId, | ||
| triggerRef, | ||
| show: showNow, | ||
| hide: hideNow, | ||
| hide: hideFromTouch, | ||
| }); | ||
| touchDismissRef.current = {arm: armOutsideDismiss, disarm: clearTapOpen}; |
There was a problem hiding this comment.
This block is the same as useTooltip.tsx:375-439 apart from the component name and one option: the touchDismissRef bridge, hideFromTouch, the usePressPin call and the touchTrigger override. A fix to how a pin closes on an outside press would then have to land twice. Could usePressPin (or one Layer hook) call useTouchTriggerInternal itself and hand back the touch handles, so each hook makes one call?
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [feat] Tooltip and HoverCard (and `useTooltip`, `useHoverCard`) take `pressTrigger` (types `TooltipPressTrigger`, `HoverCardPressTrigger`): `none` (the default, unchanged) or `toggle`. With `toggle` on a button trigger, a click, a tap, Enter, or Space pins the layer open and the same press closes it, while hover and focus still preview it. A pinned layer 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 layer is announced once when it pins, inside a modal too (`component:Tooltip` FR9 and FR10, `component:HoverCard` 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. `touchTrigger="tap"` is deprecated in favor of `pressTrigger="toggle"` in the next patch (DEP-0016). |
There was a problem hiding this comment.
Changes requested: triggerBehavior behaves as component:Tooltip FR9 and FR10 describe for a trigger in the page, an engineering owner approved the record change for this revision, and the pull request is now under 2,000 authored lines, but one FR9 case is not met. A pinned tooltip whose trigger renders in another document, such as an iframe or a Picture-in-Picture window, stays pinned when focus moves to another control, because handleFocusLeave checks relatedTarget against this window's Node (packages/core/src/Layer/usePressPin.ts:370); a press outside and Escape do not reach it there either. Please restore the trigger-window check from the previous revision (about one line), or record the other-document focus close as an FR9 implementation gap until the stacked follow-up lands.
[Automated review]
| // A press decides focus that leaves for no element. A press on the | ||
| // layer's own text moves focus to the body and keeps the pin. A press | ||
| // outside closes it through the outside dismissal. | ||
| if (!(next instanceof Node)) { |
There was a problem hiding this comment.
This tests relatedTarget against this window's Node. When the trigger renders in an iframe or a Picture-in-Picture window, the next control is a Node of that window, so this returns before close() and the tooltip stays pinned after focus moves away (FR9: "focus moving outside them closes it"). A press outside and Escape do not reach it there either. The previous revision's check fixes it in about one line:
const trigger = triggerRef.current;
const view = trigger?.ownerDocument.defaultView;
if (view == null || !(next instanceof view.Node)) {
return true;
}If it stays in the stacked follow-up, FR9 and Current-state impact should record the gap, as they do for the own-text clause.
| // for WCAG 1.4.13 (Content on Hover or Focus: hoverable). | ||
| const scheduleHide = useCallback(() => { | ||
| if (isOpen === true) { | ||
| // A pinned tooltip stays when the pointer or focus leaves. |
There was a problem hiding this comment.
Optional (non-blocking): this restates isPressHeldOpen() on the next line, so the comment can go.
e8efbb9 to
724181f
Compare
|
Updated in 724181f. The trigger-window check in |
|
/approve-spec 724181f |
… with triggerBehavior evidence Two refinements of the toggle's press pin, carried here by the maintainers' ruling so meta#9232 stays under 2,000 lines: - Under `triggerBehavior="toggle"`, Space on a `role="button"` trigger acts on keyup, as on a native button. The keydown still prevents the page scroll. A click with no pointer while Space is down, or in a key press's task, is that same press, so a trigger that clicks itself on Space keydown or keyup pins once. A keyup with no keydown on the trigger does nothing. - The shared touch trigger's outside dismissal also listens on the trigger's own document. So a tap-opened or pinned Tooltip, and a tap-opened HoverCard, whose trigger renders in an iframe closes on a tap or press outside there, or a scroll starting outside (`component:Tooltip` FR5 and FR9, `component:HoverCard` FR5). The evidence for `component:Tooltip` FR5 and FR9's `triggerBehavior` verification row: - Tooltip.test.tsx: `adaptive` by default and explicitly, `hover`, and `toggle`, each under a mouse hover and keyboard focus (both preview it), a touch and a pen tap (which opens it, never opens it, or pins it), and a mouse click and a tap on a button trigger, which only the toggle pins; an explicit `touchTrigger` decides taps beside `adaptive` and is ignored beside `hover` and `toggle`. - TouchTrigger.a11y.chromium.spec.ts: a real finger and a pen-typed press on the new TriggerBehaviors story: a tap never opens `hover`, opens `adaptive`, and pins `toggle`. - useTooltip.test.tsx: FR9's `useTooltip` clause with a caller's trigger 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. - The Tooltip record's `triggerBehavior` verification row names this evidence in place of its gap.
There was a problem hiding this comment.
Changes requested: triggerBehavior pins and closes as component:Tooltip FR9 and FR10 describe, and the record change has an engineering owner's approval for this head, but two defects remain in the pin's press handling.
- The wrapper's
stopPressPinClickcalls React'sstopPropagation(), which also stops the native click, so a page's owndocumentorwindowclick listeners never see a pinning press on a child trigger; stopping it in the React tree only, asLayer/layerClickBoundary.tsdoes, keeps the row and card stop and passes the existing suites. - A tooltip whose trigger renders in an iframe or Picture-in-Picture window stays pinned after a press outside there, because the outside dismissal listens on the page's
document; arm it on the trigger's own document, or record the gap in FR9 until the follow-up lands.
[Automated review]
| */ | ||
| export function stopPressPinClick(event: ReactMouseEvent): void { | ||
| if (pressPinClicks.has(event.nativeEvent)) { | ||
| event.stopPropagation(); |
There was a problem hiding this comment.
React's stopPropagation() also calls the native one, so document and window click listeners never see a pinning press on a child trigger (in Chromium a document listener counts 0 here, 1 on the base and on the anchorRef path). FR9 only needs the press kept from the row, card or label around the trigger. A React-tree-only stop, as Layer/layerClickBoundary.ts does, keeps that and lets page listeners see the press:
if (pressPinClicks.has(event.nativeEvent)) {
event.isPropagationStopped = () => true;
}| } else { | ||
| setPinned(true); | ||
| current.show(); | ||
| armOutsideDismiss(); |
There was a problem hiding this comment.
This arms the shared outside dismissal, which listens on the page's document (useTouchTrigger.ts:421-422). For a trigger rendered in an iframe or Picture-in-Picture window, a press outside there never reaches it, so the pin stays (aria-expanded="true"), against FR9's "a press outside the trigger and the surface … closes it". Arming it on triggerRef.current?.ownerDocument ?? document fixes this and the tap-open case, or FR9 can record the gap until the follow-up lands.
| // A string goes straight to useAnnounce from the press handler, with no | ||
| // Effect. |
There was a problem hiding this comment.
Optional (non-blocking): this narrates the call below it, so the comment can go (INV29).
724181f to
56fa37a
Compare
|
Updated in 56fa37a (16 files, 1,996 authored lines).
This head needs a spec owner's |
|
/approve-spec 56fa37a |
… with triggerBehavior evidence Two refinements of the toggle's press pin, carried here by the maintainers' ruling so meta#9232 stays under 2,000 lines: - Under `triggerBehavior="toggle"`, Space on a `role="button"` trigger acts on keyup, as on a native button. The keydown still prevents the page scroll. A click with no pointer while Space is down, or in a key press's task, is that same press, so a trigger that clicks itself on Space keydown or keyup pins once. A keyup with no keydown on the trigger does nothing. - The shared touch trigger's outside dismissal also listens on the trigger's own document. So a tap-opened or pinned Tooltip, and a tap-opened HoverCard, whose trigger renders in an iframe closes on a tap or press outside there, or a scroll starting outside (`component:Tooltip` FR5 and FR9, `component:HoverCard` FR5). FR9's gap sentence about the pin in another document goes. The evidence for `component:Tooltip` FR5 and FR9's `triggerBehavior` verification row: - Tooltip.test.tsx: `adaptive` by default and explicitly, `hover`, and `toggle`, each under a mouse hover and keyboard focus (both preview it), a touch and a pen tap (which opens it, never opens it, or pins it), and a mouse click and a tap on a button trigger, which only the toggle pins; an explicit `touchTrigger` decides taps beside `adaptive` and is ignored beside `hover` and `toggle`. - TouchTrigger.a11y.chromium.spec.ts: a real finger and a pen-typed press on the new TriggerBehaviors story: a tap never opens `hover`, opens `adaptive`, and pins `toggle`. - useTooltip.test.tsx: FR9's `useTooltip` clause with a caller's trigger 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. - The Tooltip record's `triggerBehavior` verification row names this evidence in place of its gap.
There was a problem hiding this comment.
Changes requested: triggerBehavior pins and closes as component:Tooltip FR9 and FR10 describe, the earlier page-listener and other-document points are addressed, and the record change has an engineering owner's approval for this head, but two small fixes remain.
stopPressPinClickrepeats the React-tree-only stop thatLayer/layerClickBoundary.tsalready owns asstopInReactTree(usePressPin.ts:56); please export that helper and call it, so both layer stops change together.- The changeset and the Tooltip and
useTooltipdocs say Astryx clickable rows ignore a press on ananchorRefor caller's trigger, but an Item row still runs when that trigger is not a native<button>(the gap FR9 now records); please add that exception or narrow the wording.
Optional: the comment above isPressHeldOpen() in useTooltip.tsx restates the call and can go. After the fix, the new head needs an engineering owner's /approve-spec with its full SHA, which the author may post as an engineering owner.
[Automated review]
| */ | ||
| export function stopPressPinClick(event: ReactMouseEvent): void { | ||
| if (pressPinClicks.has(event.nativeEvent)) { | ||
| event.isPropagationStopped = () => true; |
There was a problem hiding this comment.
This is the stop Layer/layerClickBoundary.ts already owns as stopInReactTree (its lines 57-66). Both rely on React's dispatch asking isPropagationStopped() before each listener, so a fix to one would miss the other. Could you export stopInReactTree from layerClickBoundary.ts and call it here?
export function stopPressPinClick(event: ReactMouseEvent): void {
if (pressPinClicks.has(event.nativeEvent)) {
stopInReactTree(event);
}
}| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [feat] Tooltip and `useTooltip` take `triggerBehavior` (type `TooltipTriggerBehavior`). `adaptive`, the default, keeps the released behavior. `hover` previews the tooltip on hover and focus, and no touch or pen tap opens it. `toggle` pins the tooltip on a click, tap, Enter, or Space on a button trigger, and the same press closes it. Escape, a press outside, or focus leaving also closes it. The press stops at the trigger: its default action is prevented, the trigger's own handlers still run, and a clickable row, card, or label around it does nothing. With `anchorRef` or a caller's own trigger, a plain `onClick` element around the trigger still receives the press. The trigger reports `aria-expanded` and `aria-controls`, and the tooltip's text is announced once when it pins. A trigger that is not a button gets a development warning. `touchTrigger` now decides taps only under `adaptive`. |
There was a problem hiding this comment.
With an anchored or caller's trigger that is not a native <button> (a role="button" span, say), an Item row around it still runs, because Item's row click skips only native controls; FR9 records this gap. As written, the notes say a clickable row does nothing apart from a plain onClick element. Could this sentence, and the matching ones in Tooltip.doc.mjs, the Tooltip JSDoc and useTooltip's JSDoc and doc, name that exception (or narrow to native-button triggers)?
| // for WCAG 1.4.13 (Content on Hover or Focus: hoverable). | ||
| const scheduleHide = useCallback(() => { | ||
| if (isOpen === true) { | ||
| // A pinned tooltip stays when the pointer or focus leaves. |
There was a problem hiding this comment.
Optional (non-blocking): this restates isPressHeldOpen() on the next line, so the comment can go.
`component:Tooltip` FR9 and FR10, `spec:AST-003` FR4: - `triggerBehavior` on Tooltip and useTooltip, with the type TooltipTriggerBehavior: `adaptive`, the default and the released behavior (a tap opens the tooltip 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 tooltip and the same press closes it. - A pinned tooltip stays until Escape, a second press, a press or scroll outside (the touch trigger's outside dismissal, which the pin arms: the pin owns the layer's touch trigger, so useTooltip makes one usePressPin call), or focus moving onto an element outside the trigger and the tooltip (the pin listens for it on the trigger, whatever `focusTrigger` is, in the trigger's own document); a press on the tooltip's own text keeps it. It takes Escape before the layer beneath it. A `triggerBehavior` that changes after mount wires or unwires the trigger, and a tooltip whose `triggerBehavior` turns to `adaptive` while pinned closes on leave again. - The press stops at its trigger, in the React tree only, through `layerClickBoundary`'s `stopInReactTree`: its default action is prevented, the trigger's own handlers still run, and page-level click listeners still see it. 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 (FR9). The trigger carries aria-expanded and aria-controls on a button trigger, and the tooltip's rendered text is announced once when it pins, through useAnnounceRenderedText (`spec:AST-086` FR12). - A non-button trigger gets one development warning and keeps tap-only opening (`Layer/usePressPin.ts`, the hover layers' shared press pin). - `TooltipTriggerBehavior` is a closed union; the API report lists it. - LayerTriggerBehavior and the touch trigger's armOutsideDismiss (useTouchTriggerInternal) stay internal: neither is exported from the Layer entry point, and the public useTouchTrigger return is unchanged. - FR9 records two gaps, each with a current-state item: a pin whose trigger renders in another document does not yet close on a press outside there, and an Item row still runs on a press of an anchored or caller's trigger that is not a native button. - The changeset, docs and JSDoc name the Item-row exception for an anchored or caller's trigger that is not a native button.
56fa37a to
11693c4
Compare
|
Updated in 11693c4 (17 files, 1,999 authored lines).
This head needs a spec owner's |
|
/approve-spec 11693c4 |
… with triggerBehavior evidence Two refinements of the toggle's press pin, carried here by the maintainers' ruling so meta#9232 stays under 2,000 lines: - Under `triggerBehavior="toggle"`, Space on a `role="button"` trigger acts on keyup, as on a native button. The keydown still prevents the page scroll. A click with no pointer while Space is down, or in a key press's task, is that same press, so a trigger that clicks itself on Space keydown or keyup pins once. A keyup with no keydown on the trigger does nothing. - The shared touch trigger's outside dismissal also listens on the trigger's own document. So a tap-opened or pinned Tooltip, and a tap-opened HoverCard, whose trigger renders in an iframe closes on a tap or press outside there, or a scroll starting outside (`component:Tooltip` FR5 and FR9, `component:HoverCard` FR5). FR9's gap sentence about the pin in another document goes. The evidence for `component:Tooltip` FR5 and FR9's `triggerBehavior` verification row: - Tooltip.test.tsx: `adaptive` by default and explicitly, `hover`, and `toggle`, each under a mouse hover and keyboard focus (both preview it), a touch and a pen tap (which opens it, never opens it, or pins it), and a mouse click and a tap on a button trigger, which only the toggle pins; an explicit `touchTrigger` decides taps beside `adaptive` and is ignored beside `hover` and `toggle`. - TouchTrigger.a11y.chromium.spec.ts: a real finger and a pen-typed press on the new TriggerBehaviors story: a tap never opens `hover`, opens `adaptive`, and pins `toggle`. - useTooltip.test.tsx: FR9's `useTooltip` clause with a caller's trigger 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. - The Tooltip record's `triggerBehavior` verification row names this evidence in place of its gap.
… with triggerBehavior evidence Two refinements of the toggle's press pin, carried here by the maintainers' ruling so meta#9232 stays under 2,000 lines: - Under `triggerBehavior="toggle"`, Space on a `role="button"` trigger acts on keyup, as on a native button. The keydown still prevents the page scroll. A click with no pointer while Space is down, or in a key press's task, is that same press, so a trigger that clicks itself on Space keydown or keyup pins once. A keyup with no keydown on the trigger does nothing. - The shared touch trigger's outside dismissal also listens on the trigger's own document. So a pinned Tooltip whose trigger renders in an iframe closes on a press outside there, and a tap-opened Tooltip or HoverCard closes on a scroll starting outside there, and on a tap outside when its trigger takes no focus (`component:Tooltip` FR5 and FR9, `component:HoverCard` FR5). FR9's gap sentence about the pin in another document goes. The evidence for `component:Tooltip` FR5 and FR9's `triggerBehavior` verification row: - Tooltip.test.tsx: `adaptive` by default and explicitly, `hover`, and `toggle`, each under a mouse hover and keyboard focus (both preview it), a touch and a pen tap (which opens it, never opens it, or pins it), and a mouse click and a tap on a button trigger, which only the toggle pins; an explicit `touchTrigger` decides taps beside `adaptive` and is ignored beside `hover` and `toggle`. - TouchTrigger.a11y.chromium.spec.ts: a real finger and a pen-typed press on the new TriggerBehaviors story: a tap never opens `hover`, opens `adaptive`, and pins `toggle`. - useTooltip.test.tsx: FR9's `useTooltip` clause with a caller's trigger 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. - The Tooltip record's `triggerBehavior` verification row names this evidence in place of its gap.
There was a problem hiding this comment.
Approval recommended: triggerBehavior pins and closes the tooltip as component:Tooltip FR9 and FR10 describe. The record change has an engineering owner's approval for this head, and the earlier shared-stop and changeset points are fixed.
- Nothing blocking remains. The
FR5, FR9 (triggerBehavior)matrix and FR9's own-text pin stay named evidence gaps in the record, for the stacked follow-ups to close.
[Automated review]
… with triggerBehavior evidence Two refinements of the toggle's press pin, carried here by the maintainers' ruling so meta#9232 stays under 2,000 lines: - Under `triggerBehavior="toggle"`, Space on a `role="button"` trigger acts on keyup, as on a native button. The keydown still prevents the page scroll. A click with no pointer while Space is down, or in a key press's task, is that same press, so a trigger that clicks itself on Space keydown or keyup pins once. A keyup with no keydown on the trigger does nothing. - The shared touch trigger's outside dismissal also listens on the trigger's own document. So a pinned Tooltip whose trigger renders in an iframe closes on a press outside there, and a tap-opened Tooltip or HoverCard closes on a scroll starting outside there, and on a tap outside when its trigger takes no focus (`component:Tooltip` FR5 and FR9, `component:HoverCard` FR5). FR9's gap sentence about the pin in another document goes. The evidence for `component:Tooltip` FR5 and FR9's `triggerBehavior` verification row: - Tooltip.test.tsx: `adaptive` by default and explicitly, `hover`, and `toggle`, each under a mouse hover and keyboard focus (both preview it), a touch and a pen tap (which opens it, never opens it, or pins it), and a mouse click and a tap on a button trigger, which only the toggle pins; an explicit `touchTrigger` decides taps beside `adaptive` and is ignored beside `hover` and `toggle`. - TouchTrigger.a11y.chromium.spec.ts: a real finger and a pen-typed press on the new TriggerBehaviors story: a tap never opens `hover`, opens `adaptive`, and pins `toggle`. - useTooltip.test.tsx: FR9's `useTooltip` clause with a caller's trigger 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. - The Tooltip record's `triggerBehavior` verification row names this evidence in place of its gap.
… with triggerBehavior evidence (#9406) fix(Tooltip): Space on keyup and a press outside in another document, with triggerBehavior evidence Two refinements of the toggle's press pin, carried here by the maintainers' ruling so #9232 stays under 2,000 lines: - Under `triggerBehavior="toggle"`, Space on a `role="button"` trigger acts on keyup, as on a native button. The keydown still prevents the page scroll. A click with no pointer while Space is down, or in a key press's task, is that same press, so a trigger that clicks itself on Space keydown or keyup pins once. A keyup with no keydown on the trigger does nothing. - The shared touch trigger's outside dismissal also listens on the trigger's own document. So a pinned Tooltip whose trigger renders in an iframe closes on a press outside there, and a tap-opened Tooltip or HoverCard closes on a scroll starting outside there, and on a tap outside when its trigger takes no focus (`component:Tooltip` FR5 and FR9, `component:HoverCard` FR5). FR9's gap sentence about the pin in another document goes. The evidence for `component:Tooltip` FR5 and FR9's `triggerBehavior` verification row: - Tooltip.test.tsx: `adaptive` by default and explicitly, `hover`, and `toggle`, each under a mouse hover and keyboard focus (both preview it), a touch and a pen tap (which opens it, never opens it, or pins it), and a mouse click and a tap on a button trigger, which only the toggle pins; an explicit `touchTrigger` decides taps beside `adaptive` and is ignored beside `hover` and `toggle`. - TouchTrigger.a11y.chromium.spec.ts: a real finger and a pen-typed press on the new TriggerBehaviors story: a tap never opens `hover`, opens `adaptive`, and pins `toggle`. - useTooltip.test.tsx: FR9's `useTooltip` clause with a caller's trigger 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. - The Tooltip record's `triggerBehavior` verification row names this evidence in place of its gap.
…#9711) * fix(Tooltip): remove the unreleased triggerBehavior prop; InfoTip pins through an internal path triggerBehavior and TooltipTriggerBehavior landed on main in #9232 and were never released. Tooltip and useTooltip drop them, and touchTrigger keeps deciding taps as released. InfoTip keeps its press-to-pin through the module-only TooltipWithTriggerBehavior, so its behavior and public props do not change. The Space-on-keyup pin and the other-document outside press stay. - usePressPin's internal behavior type drops the unused hover value, and its development warning no longer names the prop. - Tests use the internal path where they test press-to-pin; the hover cases go. - The a11y story and its Chromium cases use InfoTip, the public press-to-pin trigger; the anchored and focusTrigger=never cases go with the prop. - Tooltip and useTooltip docs return to their released text; InfoTip docs, its story and its changeset stop naming the prop; the trigger-behavior changeset goes; the core API report is regenerated. * spec(Tooltip, HoverCard, InfoTip): keep touchTrigger; withdraw triggerBehavior before release * fix(Tooltip): the public wrappers pin the adaptive behavior; records stop citing HoverCard FR9 CodeBunny on #9711: Tooltip and useTooltip passed a spread or untyped triggerBehavior through to the press-to-pin path at runtime. Both now pin triggerBehavior to adaptive, with a regression test each. AST-003 FR4, its current-state list and the overlay-dismissal Tooltip/HoverCard row no longer cite component:HoverCard FR9, which the records commit removes; a Tooltip pin cites Tooltip FR9 and a HoverCard has no press pin. Tooltip's tap guidance points an info icon at InfoTip. * docs(AST-003, Tooltip): no HoverCard press pin in AST-003; touchTrigger tap docs point info icons at InfoTip CodeBunny on #9711: AST-003's current-state list, its FR1–FR6 verification row, its completion criterion and DEC-6 still named a HoverCard press pin, which the records commit removes. They now name only the Tooltip pin. The touchTrigger prop docs say tap is for a button whose only job is the tooltip, and point an info icon at InfoTip. * docs(overlay-dismissal, AST-090, StatusDot): no pinned HoverCard; Tooltip zh tap text points at InfoTip CodeBunny on #9711: overlay-dismissal FR8 and AST-090 FR5, its impact lines and its verification row still gave a press-pinned HoverCard an Escape rule. AST-003 FR4 and DEC-6 now name only a pinned Tooltip, so these lines do too. StatusDot FR5 cites Tooltip DEC-1 for its pin. The Chinese touchTrigger text matches the English. The wrapper comments say the option is fixed, not pinned. * docs(overlay-dismissal): the iframe example and FR8, FR9 verification rows name only a pinned Tooltip CodeBunny on #9711: two table rows still gave a pinned HoverCard Escape first. A HoverCard has no press pin, so they name only a pinned Tooltip. * style(overlay-dismissal): re-pad the two edited table rows Prettier formatting only, so the lint check passes. * Merge branch 'main' of https://github.com/meta/astryx into lane4/remove-trigger-behavior # Conflicts: # docs/families/overlay-dismissal.md
Status: the gates under Testing ran at this head, 11693c4, on main 032c4a1. It needs
/approve-specat this head.User need
Some tooltips are the only place their information lives, such as an info icon or a "What is this?" button. Touch, keyboard, and screen-reader users can't keep those tooltips open. Hover opens one, and leaving closes it.
touchTrigger="tap"opens it on a tap, but a mouse click, Enter, or Space doesn't keep it open, and nothing pins it. That makes the information hover-only, whicharchitecture:interaction-modalityrules out for content that exists nowhere else.Problem and solution fit
triggerBehavior="toggle"turns the trigger into a toggle. On a button trigger, a click, a tap, Enter, or Space pins the tooltip, and the same press closes it. Hover and focus still preview it, so every input has one way to keep the tooltip.spec:AST-003FR4, DEC-6).Current specification
component:TooltipFR9, FR10, AR6 and DEC-1, plusspec:AST-003FR4 and DEC-6, all current at 1d8696a (#9175). The prop's name and values,triggerBehavior: 'adaptive' | 'hover' | 'toggle'with default'adaptive', and FR5's rules for them come from #9379, merged as a68e0e3. The record lines this pull request changes use #9379's wording.Public delta and caller burden
triggerBehavior: 'adaptive' | 'hover' | 'toggle'onTooltipanduseTooltip, with the closed-union typeTooltipTriggerBehavior. Hover and keyboard focus preview the tooltip under every value.adaptive, the default, changes nothing. It is the released touch behavior: a tap opens the tooltip unless the trigger performs an action of its own. An explicittouchTriggerstill decides taps underadaptive, until CLN-0024 removestouchTriggerin 0.8.0.hover: no touch or pen tap opens the tooltip, and no press pins it. This is the releasedtouchTrigger="none".toggle, on a button trigger (a<button>orrole="button"): a click, a tap, Enter, or Space pins the tooltip, and the same press closes it.focusTriggeris, in the trigger's own document.onOpenChangeand doesn't change itself.aria-expanded(true only while pinned) and, while the tooltip shows,aria-controls. When the tooltip pins, the shared rendered-text announcer reads its text once (spec:AST-086FR12), throughuseAnnounce. Inside a modal, that announcement plays in the modal's own region (FR14).<label>around it doesn't operate its control. WithanchorRef, oruseTooltipwith a caller's trigger, the caller's own handlers still receive the press. A plainonClickelement around the trigger receives the press unless the trigger'sonClickstops it. Astryx clickable rows, cards, and containers ignore the press. One recorded gap: an Item row still runs on such a trigger when it is not a native button, until feat(Tooltip): a trigger whose tooltip repeats its own text pins without toggle state #9361.hoverortoggle,touchTriggeris ignored.Before and after:
Not in this pull request (each stacked above, in this order; all ship in the same release):
triggerBehaviormatrix evidence (FR5 and FR9'striggerBehaviorverification row): fix(Tooltip): Space on keyup and a press outside in another document, with triggerBehavior evidence #9406. Here that row stays a named evidence gap. fix(Tooltip): Space on keyup and a press outside in another document, with triggerBehavior evidence #9406 also carries, by the maintainers' ruling, Space on keyup for arole="button"trigger, and the press-outside close for a trigger in another document, which FR9 records here as a gap.triggerBehavioron the same press pin: feat(HoverCard): triggerBehavior="toggle" pins the card on a press #9291.touchTrigger="tap", with its codemod: feat(Tooltip, HoverCard, cli): deprecate touchTrigger="tap" (DEP-0016), with its upgrade codemod #9246.Supersedes: nothing. This pull request carries the toggle itself.
API changes
These are added public rows, decided by
component:TooltipFR9 and FR10 (#9175). They go to human review underarchitecture:public-component-apiINV25.packages/core/api-report.mdlists exactly these rows.@astryxdesign/coreTooltipProps.triggerBehavior?: TooltipTriggerBehavior(default'adaptive')<Tooltip content="…" triggerBehavior="toggle"><Button label="What is this?">?</Button></Tooltip>@astryxdesign/coreTooltipOptions.triggerBehavior?: TooltipTriggerBehavior(default'adaptive')useTooltip({triggerBehavior: 'toggle'})@astryxdesign/coretype TooltipTriggerBehavior = 'adaptive' | 'hover' | 'toggle'const mode: TooltipTriggerBehavior = 'toggle';Design and alternatives
Layer/usePressPin.ts. It owns the layer's touch trigger (useTouchTriggerInternal), souseTooltipmakes oneusePressPincall (architecture:react-component-runtimeINV16). The touch trigger getstapundertoggle(the pin decides),noneunderhover, and the caller'stouchTriggerunderadaptive.Layer/layerClickBoundary.ts'sstopInReactTree, which the layer roots use too. Page-level listeners still see the press.LayerTriggerBehaviorand the touch trigger'sarmOutsideDismissstay off theLayerentry point. The publicuseTouchTriggerreturn is unchanged.aria-expandedandaria-controlswhile it wires a button trigger, and restores the trigger's own values when it unwires.Evidence
layerDismissalFamilies.test.tsxfails.stopPropagation()in the wrapper's stop (724181f's), the clickable-row case fails: adocumentclick listener sees 0 of its 2 presses.useAnnounce(inside a modal too), a scroll outside, a press on the tooltip's own text, atriggerBehaviorchange after mount, the singleusePressPincall, thefocusTrigger="never"close, and thehovermapping.Layer/usePressPin.test.tsx(33 tests): click, tap, Enter, and Space pin. Pointer leave and a press on the tooltip's own text keep the pin. Escape, a second press, a press outside, a scroll starting outside, and focus leaving close it. Focus leaving also closes it underfocusTrigger="never"and for a trigger in another document. The file also covers the controlled case, the non-button warning,triggerBehaviorchanges, the trigger state, one announcement (inside a modal Dialog too), the stop inside a clickable row (with a page-level listener that still sees each press), a ClickableCard, an Item row, and a<label>, and theanchorRefcases.layerDismissalFamilies.test.tsx: a pinned Tooltip over a Dialog takes Escape first, and the Dialog stays open.Layer/usePressPin.calls.test.tsx: the host makes oneusePressPincall per render, and every touch-trigger call comes from inside it.hooks/useAnnounceRenderedText.adopters.test.tsx: a pinned Tooltip hands its text to the shared announcer and announces none of it itself (architecture:react-component-runtimeINV10).TouchTrigger.a11y.chromium.spec.ts, on the newa11y/Tooltip toggle behaviorstories: a real tap pins and the next tap closes, a tap outside closes, Enter pins and Space closes, and inside a ClickableCard the tap pins and the card stays shut. Under a mouse, a click on the tooltip's own text keeps the pin, an anchored trigger runs its own click handler and pins, and withfocusTrigger="never", Tab to another control closes a pin.Tooltip.spec.md):anchorRefand foruseTooltipwith a caller's trigger, with aFR9 (anchorRef)verification row.triggerBehaviorverification row names its evidence gap.system_specsaddsspec:AST-086/FR12and/FR14, and apath-applicabilityblock linksLayer/usePressPin.ts. Those links replace the citations that its source comments dropped.Tooltip.tsx, and fix(HoverCard): focusTrigger="auto" decides when focus arrives, through Tooltip's shared check #9597 movesuseTooltip'sisFocusForTriggerintoutils/triggerFocus.ts. Whichever lands second rebases.Split
Four pieces stack above this one, by the maintainers' rulings, and all ship in the same release: #9406, #9361, #9291, and #9246 (see above). This one is 17 files, +1,935/−64 (1,999 lines): the shared press pin and touch-trigger wiring, Tooltip's wiring, its tests and stories, its record lines and docs, its API report rows, and its changeset. Space on keyup moved to #9406, by the maintainers' ruling, to keep this one under 2,000 lines, and so did the press-outside close for a trigger in another document. Rebased onto main 032c4a1, past #9366 (focus counting), #9417, #9398, #9531, #9516 (comment provenance), and #9589 (API reports).
Scope
Writing rubric results
The rubric in
docs/contributing/spec-writing.md, over the changed parts ofTooltip.spec.md:Testing
Local gates at this head, 11693c4 (on main 032c4a1). Since a59321c821, the code changes only by the shared stop helper and comments, so this head re-runs the static checks, the press-pin suites, and both browsers:
pnpm check:knowledge,pnpm check:changesets,pnpm check:i18n-runtime, coretsc(0 errors),ASTRYX_STRICT_LINT=1 pnpm lint(0 errors,check:repoincluded), Prettier on the touched files, and the Storybook build. The two touched.doc.mjsfiles stay unformatted, as on main, and load.stopInReactTreeis not a package export.TouchTrigger.a11y.chromium.spec.tsin Chromium: 19 of 19, twice..a11y.browser.spec.tsspecs, 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.pnpm test:uipasses 730 files, 18,147 tests;pnpm test:nodepasses 16,011, with 2 expected failures.