Repository navigation
refactor(InfoTip): build on useTooltip's show() and hide(); remove the internal toggle path - #9756
Conversation
…e internal toggle path InfoTip renders its button and the tooltip layer, with no wrapper node. useTooltip's ref sits on the button beside the hit-area ref. The button's onClick toggles show() and hide() and stops the press in the React tree, so a clickable row, card, or label around it does nothing. A mouse or pen press on a hover preview calls show() in the capture phase, so the hook's press-to-dismiss leaves the held tip in view: it pins without blinking. Touch and keyboard pin through the click. The button carries aria-describedby, aria-expanded while pinned, and aria-controls while the help shows. There are no effects. TooltipWithTriggerBehavior, useTooltipWithTriggerBehavior and Layer/usePressPin.ts go. Tooltip.tsx is the single component again. The hold behind show() and hide() and the tooltip's touch trigger move to the module-internal Tooltip/useTooltipHold.ts, one call per useTooltip. usePressPin.test.tsx moves to InfoTip/InfoTip.pin.test.tsx as InfoTip cases, with a no-wrapper DOM case, a pen case, and a case that a mouse press on a preview never hides it. Cases for the removed capabilities (role=button key handling, the non-button warning, anchorRef and controlled toggles) go with it.
InfoTip is a native button that pins its help through useTooltip's public show() and hide(). Tooltip has no toggle option; the hold and the touch trigger run in one internal owner per useTooltip call. Behavior is unchanged. Update the Tooltip, InfoTip, StatusDot, AST-003 and overlay-dismissal records to match, and point verification at the moved pin tests.
…ts click pins it aria-expanded turns true on the click, as before, not on the press.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
/approve-spec 90d5b16 |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| LayerProvider | 61.8 kB (−1.1 kB) · 10.5 kB CSS (0) | — | ✓ · ✓ · ✗ |
| InfoTip · Storybook | 36.7 kB (−1.4 kB) · 6.1 kB CSS (−89 B) | 160 (+47) | — · ✓ · ✗ |
| HoverCard | 19.0 kB (+14 B) · 5.0 kB CSS (0) | — | — · — · — |
111 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| CommandPalette | 49.1 kB (+1 B) · 12.3 kB CSS (0) | — | — · — · — |
| Text | 7.4 kB (−1 B) · 6.0 kB CSS (0) | — | — · — · — |
| Heading | 7.9 kB (−2 B) · 6.0 kB CSS (0) | — | — · — · — |
| ChatToolCalls | 25.8 kB (−15 B) · 9.3 kB CSS (0) | — | — · — · — |
| Timestamp | 21.3 kB (−17 B) · 9.9 kB CSS (0) | — | — · — · — |
| ChatMessageList | 22.8 kB (−19 B) · 7.9 kB CSS (0) | — | — · — · — |
| Timer | 9.5 kB (−24 B) · 7.0 kB CSS (0) | — | — · — · — |
| ProgressBar | 10.8 kB (−31 B) · 7.3 kB CSS (0) | — | — · — · — |
| Spinner | 18.5 kB (−33 B) · 6.8 kB CSS (0) | — | — · — · — |
| CommandPaletteInput | 26.8 kB (−38 B) · 8.5 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 56.4 kB (−63 B) · 9.9 kB CSS (0) | — | — · — · — |
| AvatarGroupOverflow | 38.3 kB (−919 B) · 6.6 kB CSS (0) | — | — · — · — |
| Avatar | 34.3 kB (−929 B) · 6.5 kB CSS (0) | — | — · — · — |
| AvatarGroup | 37.0 kB (−950 B) · 6.6 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 70.2 kB (−964 B) · 722 B CSS (0) | — | — · — · — |
| lab/CommentPin | 46.5 kB (−965 B) · 1.2 kB CSS (0) | — | — · — · — |
| SideNavItem | 54.2 kB (−981 B) · 10.5 kB CSS (0) | — | — · — · — |
| Table | 84.4 kB (−981 B) · 16.1 kB CSS (0) | — | — · — · — |
| TimeInput | 90.0 kB (−994 B) · 14.3 kB CSS (0) | — | — · — · — |
| SideNavHeading | 58.6 kB (−998 B) · 10.6 kB CSS (0) | — | — · — · — |
| NumberInput | 54.5 kB (−1003 B) · 11.2 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 222.9 kB (−1004 B) · 454 B CSS (0) | — | — · — · — |
| DropdownMenu | 73.0 kB (−1007 B) · 15.5 kB CSS (0) | — | — · — · — |
| Pagination | 86.2 kB (−1009 B) · 16.0 kB CSS (0) | — | — · — · — |
| lab/MobileTokenizer | 101.5 kB (−1010 B) · 880 B CSS (0) | — | — · — · — |
| ContextMenu | 74.9 kB (−1011 B) · 15.4 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 75.7 kB (−1012 B) · 15.6 kB CSS (0) | — | — · — · — |
| TopNavHeading | 58.0 kB (−1013 B) · 10.4 kB CSS (0) | — | — · — · — |
| lab/TransferList | 74.1 kB (−1015 B) · 1.7 kB CSS (0) | — | — · — · — |
| MoreMenu | 73.3 kB (−1019 B) · 15.5 kB CSS (0) | — | — · — · — |
| RadioListItem | 50.6 kB (−1019 B) · 10.1 kB CSS (0) | — | — · — · — |
| TextInput | 52.3 kB (−1019 B) · 11.0 kB CSS (0) | — | — · — · — |
| ComplexSelector | 55.2 kB (−1022 B) · 11.1 kB CSS (0) | — | — · — · — |
| Typeahead | 62.4 kB (−1022 B) · 11.8 kB CSS (0) | — | — · — · — |
| Selector | 77.3 kB (−1023 B) · 15.7 kB CSS (0) | — | — · — · — |
| InputGroup | 41.3 kB (−1.0 kB) · 8.4 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 80.5 kB (−1.0 kB) · 1.9 kB CSS (0) | — | — · — · — |
| FieldLabel | 35.3 kB (−1.0 kB) · 5.9 kB CSS (0) | — | — · — · — |
| Markdown | 145.3 kB (−1.0 kB) · 18.4 kB CSS (0) | — | — · — · — |
| lab/Comments | 256.4 kB (−1.0 kB) · 2.5 kB CSS (0) | — | — · — · — |
| SegmentedControl | 81.5 kB (−1.0 kB) · 7.8 kB CSS (0) | — | — · — · — |
| FileInput | 53.2 kB (−1.0 kB) · 10.8 kB CSS (0) | — | — · — · — |
| Field | 39.1 kB (−1.0 kB) · 7.4 kB CSS (0) | — | — · — · — |
| MobileNav | 49.6 kB (−1.0 kB) · 10.4 kB CSS (0) | — | — · — · — |
| TableCell | 76.1 kB (−1.0 kB) · 15.9 kB CSS (0) | — | — · — · — |
| Thumbnail | 49.0 kB (−1.0 kB) · 11.4 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 277.7 kB (−1.0 kB) · 2.6 kB CSS (0) | — | — · — · — |
| DateTimeInput | 159.9 kB (−1.0 kB) · 17.1 kB CSS (0) | — | — · — · — |
| RadioList | 40.6 kB (−1.0 kB) · 7.4 kB CSS (0) | — | — · — · — |
| ListItem | 52.1 kB (−1.0 kB) · 11.1 kB CSS (0) | — | — · — · — |
| ChatComposer | 60.8 kB (−1.0 kB) · 11.2 kB CSS (0) | — | — · — · — |
| DateInput | 103.2 kB (−1.0 kB) · 15.4 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 52.8 kB (−1.0 kB) · 11.1 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 58.8 kB (−1.0 kB) · 10.7 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 58.8 kB (−1.0 kB) · 10.7 kB CSS (0) | — | — · — · — |
| MultiSelector | 72.6 kB (−1.0 kB) · 15.3 kB CSS (0) | — | — · — · — |
| Slider | 88.4 kB (−1.0 kB) · 9.4 kB CSS (0) | — | — · — · — |
| CheckboxList | 42.6 kB (−1.0 kB) · 8.6 kB CSS (0) | — | — · — · — |
| Link | 42.1 kB (−1.0 kB) · 8.0 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 64.8 kB (−1.0 kB) · 1.1 kB CSS (0) | — | — · — · — |
| StatusDot | 22.4 kB (−1.0 kB) · 6.3 kB CSS (0) | — | — · — · — |
| Lightbox | 49.9 kB (−1.0 kB) · 10.2 kB CSS (0) | — | — · — · — |
| TextArea | 46.4 kB (−1.0 kB) · 9.9 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 102.6 kB (−1.0 kB) · 1.9 kB CSS (0) | — | — · — · — |
| Carousel | 50.1 kB (−1.0 kB) · 10.6 kB CSS (0) | — | — · — · — |
| Banner | 46.6 kB (−1.0 kB) · 10.3 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 64.3 kB (−1.0 kB) · 773 B CSS (0) | — | — · — · — |
| richtext/RichTextView | 258.1 kB (−1.0 kB) · 2.3 kB CSS (0) | — | — · — · — |
| Tooltip · Storybook | 20.2 kB (−1.0 kB) · 5.0 kB CSS (0) | 760 (+82) | ✓ · ✓ · ✓ |
| DateRangeInput | 69.4 kB (−1.0 kB) · 11.9 kB CSS (0) | — | — · — · — |
| Switch | 86.6 kB (−1.0 kB) · 10.6 kB CSS (0) | — | — · — · — |
| lab/Schedule | 60.8 kB (−1.1 kB) · 3.9 kB CSS (0) | — | — · — · — |
| lab/ListInput | 80.9 kB (−1.1 kB) · 1.6 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 45.0 kB (−1.1 kB) · 9.8 kB CSS (0) | — | — · — · — |
| TopNav | 51.1 kB (−1.1 kB) · 10.7 kB CSS (0) | — | — · — · — |
| TabMenu | 55.2 kB (−1.1 kB) · 10.5 kB CSS (0) | — | — · — · — |
| CheckboxInput | 48.0 kB (−1.1 kB) · 9.8 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 54.7 kB (−1.1 kB) · 10.3 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 45.6 kB (−1.1 kB) · 9.8 kB CSS (0) | — | — · — · — |
| ChatSendButton | 45.1 kB (−1.1 kB) · 9.8 kB CSS (0) | — | — · — · — |
| PowerSearch | 191.5 kB (−1.1 kB) · 21.7 kB CSS (0) | — | — · — · — |
| IconButton | 44.7 kB (−1.1 kB) · 9.8 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 45.2 kB (−1.1 kB) · 10.0 kB CSS (0) | — | — · — · — |
| TopNavMenu | 57.8 kB (−1.1 kB) · 10.5 kB CSS (0) | — | — · — · — |
| SideNav | 65.4 kB (−1.1 kB) · 10.9 kB CSS (0) | — | — · — · — |
| Button | 44.7 kB (−1.1 kB) · 9.8 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 251.2 kB (−1.1 kB) · 2.4 kB CSS (0) | — | — · — · — |
| ToggleButton | 45.6 kB (−1.1 kB) · 9.9 kB CSS (0) | — | — · — · — |
| Tokenizer | 70.1 kB (−1.1 kB) · 17.1 kB CSS (0) | — | — · — · — |
| Popover | 52.1 kB (−1.1 kB) · 12.7 kB CSS (0) | — | — · — · — |
| Toast | 58.5 kB (−1.1 kB) · 10.1 kB CSS (0) | — | — · — · — |
| ChatLayout | 47.9 kB (−1.1 kB) · 10.3 kB CSS (0) | — | — · — · — |
| Calendar | 53.5 kB (−1.1 kB) · 10.4 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 67.2 kB (−1.1 kB) · 11.5 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 45.3 kB (−1.1 kB) · 9.9 kB CSS (0) | — | — · — · — |
| AlertDialog | 81.6 kB (−1.1 kB) · 13.1 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 53.6 kB (−1.1 kB) · 11.2 kB CSS (0) | — | — · — · — |
| lab/MobilePowerSearch | 216.1 kB (−1.1 kB) · 1.2 kB CSS (0) | — | — · — · — |
| CodeBlock | 58.5 kB (−1.1 kB) · 11.1 kB CSS (0) | — | — · — · — |
| charts/ChartLegend | 24.8 kB (−1.1 kB) · 20 B CSS (0) | — | — · — · — |
| charts/ChartTooltip | 24.8 kB (−1.1 kB) · 20 B CSS (0) | — | — · — · — |
| lab/TourStep | 57.4 kB (−1.1 kB) · 590 B CSS (0) | — | — · — · — |
| Stepper | 46.3 kB (−1.1 kB) · 10.0 kB CSS (0) | — | — · — · — |
| charts/Chart | 27.2 kB (−1.2 kB) · 20 B CSS (0) | — | — · — · — |
| DrawerHeader | 47.7 kB (−1.2 kB) · 11.6 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 70.5 kB (−1.2 kB) · 2.1 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 54.4 kB (−1.2 kB) · 11.8 kB CSS (0) | — | — · — · — |
| DialogHeader | 47.6 kB (−1.2 kB) · 10.2 kB CSS (0) | — | — · — · — |
| AppShell | 67.8 kB (−1.2 kB) · 12.2 kB CSS (0) | — | — · — · — |
| layer | — | — | — · ✓ · — |
| Layer | — | — | ✓ · ✓ · — |
Package size: @astryxdesign/core 6.21 MB packed (−6.9 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: core 52 rows; run pnpm api:report.
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
|
AI review status for this pull request.
|
…hook useTooltipHold goes. useTooltip keeps the hold behind show() and hide(), calls the touch trigger itself, and listens on the trigger for focus leaving a held tooltip from its interaction ref. Its test file goes with it.
|
/approve-spec d893ab7 |
|
/approve-spec 03474f6 |
There was a problem hiding this comment.
Requesting changes: moving InfoTip onto useTooltip's show() and hide() and deleting the internal toggle path match the approved records, but the new press handling in InfoTip.tsx has two regressions.
- After a mouse or pen press on a hover preview that ends off the button,
isHeldByPressRefstays set, so the next Enter or Space skipsshow()yet sets the pin, leaving the button ataria-expanded="true"with no help that later presses cannot clear (InfoTip.tsx:206-208); callingtooltip.show()on every pinning click and removing the ref fixes it. - A right or middle press on a hover preview also calls
show(), so the tip stays open after the pointer leaves and is announced without being pinned (InfoTip.tsx:185); returning early whenevent.button !== 0fixes it. - The changeset's "What people see and hear is unchanged" is not true at this head because of those two sequences, and becomes accurate once they are fixed.
A test that presses a preview, releases outside the button and then sends a keyboard click would cover both. Non-blocking: the comment at InfoTip.tsx:178-180 reads better as three short sentences.
[Automated review]
| if (!isHeldByPressRef.current) { | ||
| tooltip.show(); | ||
| } |
There was a problem hiding this comment.
After a press that ends off the button (dragged away, or a right-click whose menu is dismissed), isHeldByPressRef is still true here. A keyboard Enter then skips show() but still sets isPinned, so the button reports aria-expanded="true" with no help. Each later press calls hide() on a closed tooltip, which never fires onHide, so it stays stuck. On a tip that is already shown and held, show() only clears timers and re-arms the outside dismissal. Calling it on every pinning click and deleting the ref fixes this.
| const handlePointerDownCapture = useCallback( | ||
| (event: PointerEvent<HTMLButtonElement>) => { | ||
| isHeldByPressRef.current = false; | ||
| if (event.pointerType === 'touch' || isPinned || !isShown) { |
There was a problem hiding this comment.
A right or middle press reaches this branch too. It turns a hover preview into an announced hold that stays after the pointer leaves, and no click follows to pin it. Suggest if (event.button !== 0 || event.pointerType === 'touch' || isPinned || !isShown) return;.
| // A mouse or pen press on a previewed tip keeps it in view: show() turns | ||
| // the preview into a hold before the hook's press handler runs, so the tip | ||
| // never blinks out between the press and its click. The click still pins. |
There was a problem hiding this comment.
Non-blocking: this is one 38-word sentence with an idiom. Suggest: "A mouse or pen press on a preview calls show() first. The hook's press-to-close then leaves it open. The click pins it."
…ess holds a preview A press on a preview that lifted off the button left a stale flag, so the next Enter or Space set the pin without show() and stuck at aria-expanded="true". A right or middle press held a preview that no click would pin. The click now always calls show(), which is safe on a held tip, and the press-hold reads only the primary button.
|
/approve-spec 02edc3a |
There was a problem hiding this comment.
Requesting changes: the follow-up fixes the stuck aria-expanded after a press released off the button and the right-click hold, but the pointer-down hold still has one gap and the changeset still overstates.
- A mouse press on a hover preview that is released on the help text leaves the help held open with
aria-expanded="false"after the pointer leaves, and the next press pins it instead of closing it (InfoTip.tsx:179-192); end that hold when no click on the button completes the press, or count that press as the pin. - The changeset's "What people see and hear is unchanged" is still not accurate: besides that sequence, a right-click on a hover preview now hides it at once, where it used to stay until the pointer left (
.changeset/infotip-on-use-tooltip.md:5).
A case that presses a preview, releases on the help surface and moves away would cover the first.
[Automated review]
| ) { | ||
| return; | ||
| } | ||
| tooltip.show(); |
There was a problem hiding this comment.
When this press is released on the help text, no click reaches the button, and the outside dismissal ignores a release inside the surface, so this hold outlives the press: the help stays open after the pointer leaves with aria-expanded="false", and the next click pins it instead of closing it. End the hold when no click on the button completes the press, or count the press as the pin.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] InfoTip renders only its button and its help: the `display: contents` wrapper around the button is gone, and the button is the tooltip's trigger directly, built on `useTooltip`'s `show()` and `hide()`. What people see and hear is unchanged: hover and keyboard focus preview the help, a click, tap, Enter, or Space pins it until Escape, a second press, a press outside, or focus leaving, and a mouse press on a previewed help keeps it in view as it pins. Styles that reached the button through a wrapper selector now select the button itself. |
There was a problem hiding this comment.
"What people see and hear is unchanged" is not accurate yet: a press on a preview released on the help text now keeps it open, and a right-click on a preview now hides it at once, where it used to stay until the pointer left. Fix the first, and mention the right-click change (or drop this sentence).
…hold No click completes such a press, so the hold ended with nothing: the help stayed open with aria-expanded="false" and the next press pinned it. The press now ends its hold when no click on the button follows its pointerup. The changeset names the right-click change: a right-click on a preview closes it, as on any tooltip trigger.
|
/approve-spec 9170ce6 |
There was a problem hiding this comment.
Requesting changes: the follow-up no longer leaves the help held open after a press released on it, and the changeset now names the right-click change, but the way it ends that hold adds two problems.
InfoTip.tsx:195-211adds a windowpointerup/pointercancellistener and a timer inside InfoTip, a second press-end path besideuseTooltip's own outside dismissal that InfoTip's FR2 and PR1 and the runtime record's INV16 rule out, so end a press-scoped hold insideuseTooltipand keep InfoTip to its oneshow()call.- The timer's
hide()(InfoTip.tsx:206) closes the help at once when a press on a preview is released on the help text, even with the pointer resting on it, where the base kept it open while hovered (Tooltip FR3), so end the hold without hiding and reword the changeset's "leaves it closed" to match.
Non-blocking: the description's "nothing changes" bullet should mention the right-click change, and the comment at InfoTip.tsx:178-182 reads better as three short sentences.
[Automated review]
| const view = event.currentTarget.ownerDocument.defaultView; | ||
| if (view == null) { | ||
| return; | ||
| } | ||
| isPressHoldPendingRef.current = true; | ||
| const endPress = () => { | ||
| view.removeEventListener('pointerup', endPress, true); | ||
| view.removeEventListener('pointercancel', endPress, true); | ||
| view.setTimeout(() => { | ||
| if (isPressHoldPendingRef.current) { | ||
| isPressHoldPendingRef.current = false; | ||
| tooltip.hide(); | ||
| } | ||
| }, 0); | ||
| }; | ||
| view.addEventListener('pointerup', endPress, true); | ||
| view.addEventListener('pointercancel', endPress, true); |
There was a problem hiding this comment.
This adds InfoTip's own window pointerup/pointercancel listener and timer to end the hold. useTooltip already ends every show() hold at a press's end through armOutsideDismiss (useTouchTrigger.ts:398-437), and InfoTip FR2/PR1 say InfoTip adds no document listener, timer or dismissal rule of its own. The listener also outlives an unmount mid-press. Suggest ending a hold made during a trigger press inside useTooltip (for example where armOutsideDismiss sees that press end on the surface), and deleting the ref, listener and timer here.
| view.setTimeout(() => { | ||
| if (isPressHoldPendingRef.current) { | ||
| isPressHoldPendingRef.current = false; | ||
| tooltip.hide(); |
There was a problem hiding this comment.
hide() closes the help even while the pointer rests on it: hover, press the "i", release on the help text, and it vanishes at release, where the base kept it open while hovered (Tooltip FR3). Ending the hold without hiding (the hook's dropHold) lets the hover rules decide, as before.
| // A primary mouse or pen press on a preview calls show() first. The hook's | ||
| // press-to-close then leaves it open. The click pins it. A press that ends | ||
| // off the button gets no click, so its hold ends with the press: the | ||
| // browser sends the click in the same task as the pointerup, before the | ||
| // timer runs. |
There was a problem hiding this comment.
Non-blocking: the last sentence is 31 words with two topics. Suggest: "A press that ends off the button gets no click. Its hold ends with the press. The browser sends the click in the same task as the pointerup, before the timer runs."
…th the press off the trigger InfoTip no longer listens for the press's end or runs a timer. useTooltip ends a hold that began during a press on its trigger when that press ends off the trigger, where no click pins it, and lets the hover rules decide: the help stays while the pointer rests on it, and closes after it leaves.
|
/approve-spec ed9a1ff |
There was a problem hiding this comment.
Requesting changes: InfoTip's move onto useTooltip's show() and hide() and the removal of the internal toggle path match the approved records, and InfoTip no longer adds a listener or timer of its own, but the press-scoped hold now in useTooltip has two problems.
holdForPress(useTooltip.tsx:619-652) adds a second capturepointerup/pointercancellistener for the same press the touch trigger's outside dismissal already watches, repeating its trigger and surface checks, so end a press-scoped hold from that dismissal's existing handler inuseTouchTrigger.tsand delete this listener.- The one-task
isFreshHoldRefflag (useTooltip.tsx:872-877) ties a hold to the press only whenshow()runs before the hook's ownpointerdownlistener, so an app button that callsshow()from an ordinaryonPointerDownor later in the press stays held open after a press released on the help, against the new FR12 sentence; track the trigger press itself (or narrow FR12 and have it re-approved), and cover it with a test and a line in theshow()JSDoc.
Non-blocking: the comments at useTooltip.tsx:615-618 and :872-873 read better shortened and placed above the code they describe (see the inline suggestions).
[Automated review]
| scheduleHide(); | ||
| } | ||
| }; | ||
| view.addEventListener('pointerup', end, true); |
There was a problem hiding this comment.
This is a second capture pointerup/pointercancel listener for the press that show() has just armed armOutsideDismiss for (useTouchTrigger.ts:398-437), with the same trigger and surface checks. A release outside is already closed there through hideFromTouch; only the release over the surface is new. Suggest ending a press-scoped hold from that handler, for example a callback useTouchTriggerInternal calls when a press ends over the surface, and deleting this listener.
| // A press on the trigger that is being dispatched now started this hold. | ||
| // The trigger's own pointerdown listener runs before the timer. | ||
| isFreshHoldRef.current = true; | ||
| triggerRef.current?.ownerDocument.defaultView?.setTimeout(() => { | ||
| isFreshHoldRef.current = false; | ||
| }, 0); |
There was a problem hiding this comment.
The flag lasts one task, and only this hook's own pointerdown listener reads it. A show() from an app's ordinary onPointerDown (React runs it after that listener) or later in the press is never tied to the press, so a press released on the help leaves the tooltip held open, which the new FR12 sentence rules out. Tracking the trigger press itself, from this hook's pointerdown until it ends, covers every show() during the press. Non-blocking: the comment above states as fact what is true only for some calls.
| // A hold that show() starts during a press on the trigger lasts only as | ||
| // long as that press when the press ends off the trigger: no click on the | ||
| // trigger follows, so nothing pins it. The hover rules then decide, as | ||
| // for a preview. |
There was a problem hiding this comment.
Non-blocking (INV29): this 35-word sentence is appended to the press-to-close comment, and holdForPress now sits between that comment and handlePointerDown, which it describes. Suggest moving the press-to-close comment down to handlePointerDown, and above holdForPress: "A show() hold made during a trigger press ends with that press if it ends off the trigger. No click follows, so nothing pins it. The hover rules then decide."
…dismissal's own release check useTooltip tracks the trigger press from its pointerdown to the press's end, so any show() during the press, from a capture handler, an ordinary onPointerDown or later, ties the hold to that press. The touch trigger's outside dismissal, which already watches the release, now reports a release inside the layer, and useTooltip ends a press-started hold there. Its own second release listener goes. The show() JSDoc names the rule, and a test covers a show() from an ordinary onPointerDown.
|
/approve-spec 1cfca1d |
There was a problem hiding this comment.
Requesting changes: InfoTip's move onto useTooltip's show() and hide() matches the approved records, and both points from the last round are fixed, but the new press tracking in useTooltip leaves one gap.
useTooltip.tsx:881: when ashow()made during a trigger press is followed by that press ending on the trigger (a normal click, or a right press),isHoldFromPressRefstays set, so the next press released inside the tooltip drops the hold and the tooltip closes when the pointer leaves, which Tooltip FR12 does not allow and the base does not do; clear the flag in the press-end listener when thepointeruplands on the trigger, and add auseTooltip.showHide.test.tsxcase for it.
InfoTip itself is not affected, because its click calls show() again. The inline notes on the show() JSDoc and the handlePointerDown comment are non-blocking.
[Automated review]
| const stop = () => { | ||
| view.removeEventListener('pointerup', stop, true); | ||
| view.removeEventListener('pointercancel', stop, true); | ||
| isTriggerPressedRef.current = false; | ||
| stopPressTrackingRef.current = null; | ||
| }; |
There was a problem hiding this comment.
When the press ends on the trigger, this resets only isTriggerPressedRef, and the outside dismissal returns early for a release on the trigger, so isHoldFromPressRef stays true on a hold Tooltip FR12 keeps. The next press released inside the tooltip then runs onReleaseInLayer, drops the hold, and the tooltip closes when the pointer leaves (an app button that calls show() from onPointerDown, after a click or a right press). Suggest clearing it here for a release on the trigger:
const trigger = triggerRef.current;
const stop = (event: Event) => {
if (
event.type === 'pointerup' &&
event.target instanceof view.Node &&
trigger?.contains(event.target) === true
) {
isHoldFromPressRef.current = false;
}
// remove the listeners and reset isTriggerPressedRef as today
};and a useTooltip.showHide.test.tsx case: click a PressShowTip, press inside the tooltip, leave, and expect it still shown.
| * Opens the tooltip now and keeps it open until `hide()`, Escape, a press | ||
| * outside, or focus leaving its trigger, as a pinned tooltip does. Its text | ||
| * is announced once. Reports through `onShow`. Under a controlled `isOpen`, | ||
| * outside, or focus leaving its trigger. Called during a press on the | ||
| * trigger, it keeps the tooltip open only until that press ends: a press |
There was a problem hiding this comment.
Non-blocking: this 28-word sentence says the hold lasts "only until that press ends", but a press that ends on the trigger keeps it. Suggest: "If a press on the trigger is down when you call it, and the press ends off the trigger with no click, the hold ends. The hover rules then decide."
| // nor waits for a tap verdict. A show() from a capture handler of this | ||
| // same press ran just before this listener. |
There was a problem hiding this comment.
Non-blocking: this states as fact what is true only for some calls. Suggest: "A show() in a capture handler of this press runs before this listener. Tie that hold to the press."
A show() during a press that then ended on the trigger stayed marked as the press's, so a later press released on the tooltip dropped the hold. The press tracker clears the mark when the press ends on the trigger. A case covers it; the show() JSDoc and the pointerdown comment say it plainly.
|
/approve-spec 43ce1f1 |
There was a problem hiding this comment.
Recommending approval: InfoTip's move onto useTooltip's show() and hide() matches the approved records, and the gap from the last round is fixed. A show() made during a trigger press now keeps its hold when the press ends on the trigger, and useTooltip.showHide.test.tsx covers it.
No blocking findings remain. Two optional follow-ups: move the press-to-close comment in useTooltip.tsx down to handlePointerDown, which it describes, and say in InfoTip FR2 whether its pointer-down hold counts as a pin, since Tooltip FR9 and FR10 announce any show() hold while InfoTip keeps aria-expanded false until the click.
[Automated review]
| // is owned by the consumer. `hideLayer()` self-guards when already closed. | ||
| // A touch press is a different gesture (it may be the only way to open the | ||
| // tooltip at all), so the touch path answers it first. | ||
| // Whether a press on the trigger is down, from the hook's pointerdown to |
There was a problem hiding this comment.
Non-blocking: the press-to-close comment just above (lines 626-632) describes handlePointerDown below, and this press-tracking comment now continues it. Suggest moving the press-to-close comment down to handlePointerDown, so each comment sits above the code it explains.
…tion, and the recorded module resolutions follow core (#9851) * test(cli): the recorded module resolutions follow useLightbox's doc and drop the deleted usePressPin #9752 gave useLightbox its own doc; #9756 deleted the internal Layer/usePressPin.ts. Each was green alone because PR checks skip this fixture test; main test-node fails on both lines. * test(Tokenizer): the sheet-row test passes presentation, not the removed experimental prop #9808 added the test with experimental.presentation; #9836 removed that prop. Each was green alone; together main typecheck fails (TS2769). Same change as #9847, folded in here so one pull request turns main green. Co-authored-by: Xinzi Zhou <[email protected]>
…so Done's hand-off costs no render Done hands focus from the wheels to the shown month's tab stop. The day's focus handler recorded that day, so React rendered once more after the toggle's commit. The tab stop already names the day that a recorded focus would name. So while no day is recorded, its focus now records nothing. The test "Done hands focus from the wheels to the calendar in the toggle's commit" checks it. It fails at the parent (2 commits against 1) and passes here. Main's useTooltip change (meta#9756) removed an extra render that hid this one.
…so Done's hand-off costs no render Done hands focus from the wheels to the shown month's tab stop. The day's focus handler recorded that day, so React rendered once more after the toggle's commit. The tab stop already names the day that a recorded focus would name. So while no day is recorded, its focus now records nothing. The test "Done hands focus from the wheels to the calendar in the toggle's commit" checks it. It fails at the parent (2 commits against 1) and passes here. Main's useTooltip change (meta#9756) removed an extra render that hid this one.
InfoTip is now built directly on
useTooltip: its button callsshow()andhide(). The internal toggle path and its hooks are deleted, and nothing new replaces them.User impact
<button>plus the tooltip layer. Thedisplay: contentswrapper is gone.useTooltip, gives imperative control of a tooltip. InfoTip is its first caller.Owner's design, mapped to the code
InfoTip.tsx:const tooltip = useTooltip({onShow, onHide}). The button'sonClickcallstooltip.show()to pin andtooltip.hide()to close.useTooltip's publicshow()/hide()(already public). The hold behind them lives insideuseTooltip.tsx. InfoTip uses only those two.useTooltipWithTriggerBehavior,TooltipWithTriggerBehaviorandLayer/usePressPin.tsare deleted. No hook is added:git diff main -- packages/core/src | grep -cE '^\+.*(function use[A-Z]|const use[A-Z][A-Za-z]* *=)'→ 0.useTooltip'srefdirectly, merged with its hit-area ref.InfoTip.pin.test.tsxasserts that the only nodes in place are the button and the layer's own nodes.InfoTip.tsxonPointerDownCapture: a primary mouse or pen press on a tip shown by hover callstooltip.show()before useTooltip's press-to-close, so the tip holds in place. The click then callsshow()and pins it. InsideuseTooltip, a hold that began during a trigger press ends with that press when it ends off the trigger, so the hover rules decide again.Effects:
git diff main -- packages/core/src | grep -cE '^\+.*use(Layout)?Effect\('→ 0 added (2 removed, both usePressPin's).What changes
InfoTip.tsx: renders the button plustooltip.renderTooltip(content).stopInReactTree+preventDefault), so a clickable row, card, or label around it does nothing.aria-describedby;aria-expanded(true while pinned);aria-controlswhile the help shows.useTooltip.tsx:show()/hide(): it holds untilhide(), Escape, a press or scroll outside, or focus leaving.Tooltip.tsx: the single component again.Layer/usePressPin.test.tsx→InfoTip/InfoTip.pin.test.tsxas InfoTip cases. It adds a no-wrapper DOM case, a pen case, and a case showing that a mouse press on a preview never hides it.[fix], covering the wrapper removal.Evidence
Main merge and the phone check
handlePointerDownstarts a press tracker on every trigger press;onReleaseInLayer);show().Follow-up (not in this PR)
<Tooltip>still wraps element children in adisplay: contentsdiv. It could attach to the first child through a ref instead, which would be a separate change.Writing rubric results
The rubric in
docs/contributing/spec-writing.mdwas run over the five changed records:component:Tooltip,component:InfoTip,component:StatusDot,spec:AST-003andfamily:overlay-dismissal. Specs & Decisions wrote the record text.useTooltip'sshow()/hide(), with no internal toggle path in Tooltip.show()/hide()is closed by this change.