Skip to content

refactor(InfoTip): build on useTooltip's show() and hide(); remove the internal toggle path - #9756

Merged
cixzhang merged 13 commits into
mainfrom
lane4/infotip-use-tooltip
Nov 4, 2026
Merged

cixzhang merged 13 commits into
mainfrom
lane4/infotip-use-tooltip

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

InfoTip is now built directly on useTooltip: its button calls show() and hide(). The internal toggle path and its hooks are deleted, and nothing new replaces them.

User impact

  • People using InfoTip: nothing changes, with one exception: a right-click on a previewed tip now closes it, as on any tooltip trigger (Tooltip FR6). Mouse, keyboard and touch otherwise behave exactly as before, checked step by step in real Chrome:
    • Hover and focus preview the help.
    • A click, tap, Enter, or Space pins it.
    • Escape, a second press, a press outside, or moving focus closes it.
    • A mouse press on a tip shown by hover holds it in place, so it never hides and shows again.
  • App builders:
    • InfoTip's DOM is now just its <button> plus the tooltip layer. The display: contents wrapper is gone.
    • InfoTip's public props are unchanged.
  • Maintainers: one hook, useTooltip, gives imperative control of a tooltip. InfoTip is its first caller.

Owner's design, mapped to the code

Owner's words Where it is
"Info tip should likely useTooltip with its button component instead and the button should call show and hide on the tooltip" InfoTip.tsx: const tooltip = useTooltip({onShow, onHide}). The button's onClick calls tooltip.show() to pin and tooltip.hide() to close.
"We expose the capability through useTooltip with show and hide" / "that hook should allow for imperative control of the tool tip" / "then info tip uses that" useTooltip's public show() / hide() (already public). The hold behind them lives inside useTooltip.tsx. InfoTip uses only those two.
"it should just be useTooltip" / "No new internal hooks" / "I don't want useTooltipWithTrigger" useTooltipWithTriggerBehavior, TooltipWithTriggerBehavior and Layer/usePressPin.ts are 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.
"I wanted to eliminate this extra redirection" InfoTip no longer goes through a Tooltip component wrapper or a trigger-behavior hook. The button holds useTooltip's ref directly, merged with its hit-area ref.
"eliminate an extra dom node that's not necessary" The button renders with no wrapper. InfoTip.pin.test.tsx asserts that the only nodes in place are the button and the layer's own nodes.
"Infotip b" InfoTip.tsx onPointerDownCapture: a primary mouse or pen press on a tip shown by hover calls tooltip.show() before useTooltip's press-to-close, so the tip holds in place. The click then calls show() and pins it. Inside useTooltip, 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 plus tooltip.renderTooltip(content).
    • The click stops at the button (stopInReactTree + preventDefault), so a clickable row, card, or label around it does nothing.
    • ARIA: aria-describedby; aria-expanded (true while pinned); aria-controls while the help shows.
  • useTooltip.tsx:
    • Keeps the hold behind show()/hide(): it holds until hide(), Escape, a press or scroll outside, or focus leaving.
    • Calls the touch trigger itself.
    • Listens for focus leaving a held tooltip from its interaction ref.
  • Tooltip.tsx: the single component again.
  • Tests:
    • Layer/usePressPin.test.tsx → InfoTip/InfoTip.pin.test.tsx as 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.
    • The usePressPin calls test is deleted.
    • Cases for removed capabilities go: role=button keys, the non-button warning, and anchorRef and controlled toggles.
  • Records: Specs & Decisions' commits for Tooltip, InfoTip, StatusDot, AST-003 and overlay-dismissal, plus the press-hold sentence in InfoTip FR2.
  • Changeset: patch [fix], covering the wrapper removal.

Evidence

  • Before/after behavior in real Chrome: 14 of 14 steps identical across mouse, keyboard, touch, and a tap inside a clickable card. The layer never closes between a hover preview and its pinning click.
  • Chromium contracts: 42/42 pass (Tooltip, TooltipFocusReturn, TooltipHoverBridge, InfoTipTouch, TouchTrigger, LayerReducedMotion).
  • Unit tests: Tooltip, InfoTip, Layer, HoverCard, StatusDot, DropdownMenu, Field and the doc-prop suites pass.

Main merge and the phone check

  • Main merge: this branch merged main at acca589 with no conflicts. A range-diff showed this pull request's own changes identical before and after the merge.
  • Since the real-phone check at d893ab7, review rounds changed shared code that touch presses run through:
    • useTooltip's handlePointerDown starts a press tracker on every trigger press;
    • useTouchTrigger's outside dismissal reports a release inside the tooltip (onReleaseInLayer);
    • InfoTip's click always calls show().
  • Touch behavior is unchanged: a tap's press ends on the trigger, which clears the press mark before its click, so a tap's hold is never dropped.
  • Measured in real Chrome at 1cfca1d, 390 px touch, all identical to main: tap pins, tap again closes, tap outside closes, and a tap in a clickable card pins without opening the card. Chromium contracts 42/42.

Follow-up (not in this PR)

  • Plain <Tooltip> still wraps element children in a display: contents div. 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.md was run over the five changed records: component:Tooltip, component:InfoTip, component:StatusDot, spec:AST-003 and family:overlay-dismissal. Specs & Decisions wrote the record text.

  • R1, state the system: each record describes InfoTip as a button over useTooltip's show()/hide(), with no internal toggle path in Tooltip.
  • R2, research: none added.
  • R3, evidence cites facts: verification rows name test files and specs that exist at this head.
  • R4, rejected alternatives: none added.
  • R5, no pull request or issue references: none added.
  • R6, open questions: the InfoTip open question on adopting show()/hide() is closed by this change.

cixzhang and others added 3 commits November 3, 2026 06:24
…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.
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 3, 2026 7:18pm UTC

Request Review

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

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 90d5b16

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 43ce1f1

Storybook · Sandbox · built from this PR's head

Modified components

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

@astracat-bot

astracat-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 7:23 PM UTC

…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.
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec d893ab7

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 03474f6

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, isHeldByPressRef stays set, so the next Enter or Space skips show() yet sets the pin, leaving the button at aria-expanded="true" with no help that later presses cannot clear (InfoTip.tsx:206-208); calling tooltip.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 when event.button !== 0 fixes 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]

Comment thread packages/core/src/InfoTip/InfoTip.tsx Outdated
Comment on lines +206 to +208
if (!isHeldByPressRef.current) {
tooltip.show();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/core/src/InfoTip/InfoTip.tsx Outdated
const handlePointerDownCapture = useCallback(
(event: PointerEvent<HTMLButtonElement>) => {
isHeldByPressRef.current = false;
if (event.pointerType === 'touch' || isPinned || !isShown) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread packages/core/src/InfoTip/InfoTip.tsx Outdated
Comment on lines +178 to +180
// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: 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.
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 02edc3a

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread .changeset/infotip-on-use-tooltip.md Outdated
'@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 9170ce6

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-211 adds a window pointerup/pointercancel listener and a timer inside InfoTip, a second press-end path beside useTooltip's own outside dismissal that InfoTip's FR2 and PR1 and the runtime record's INV16 rule out, so end a press-scoped hold inside useTooltip and keep InfoTip to its one show() 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]

Comment thread packages/core/src/InfoTip/InfoTip.tsx Outdated
Comment on lines +195 to +211
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread packages/core/src/InfoTip/InfoTip.tsx Outdated
view.setTimeout(() => {
if (isPressHoldPendingRef.current) {
isPressHoldPendingRef.current = false;
tooltip.hide();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/core/src/InfoTip/InfoTip.tsx Outdated
Comment on lines +178 to +182
// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: the 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.
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec ed9a1ff

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 capture pointerup/pointercancel listener 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 in useTouchTrigger.ts and delete this listener.
  • The one-task isFreshHoldRef flag (useTooltip.tsx:872-877) ties a hold to the press only when show() runs before the hook's own pointerdown listener, so an app button that calls show() from an ordinary onPointerDown or 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 the show() 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +872 to +877
// 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +615 to +618
// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (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.
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 1cfca1d

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a show() made during a trigger press is followed by that press ending on the trigger (a normal click, or a right press), isHoldFromPressRef stays 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 the pointerup lands on the trigger, and add a useTooltip.showHide.test.tsx case 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]

Comment on lines +644 to +649
const stop = () => {
view.removeEventListener('pointerup', stop, true);
view.removeEventListener('pointercancel', stop, true);
isTriggerPressedRef.current = false;
stopPressTrackingRef.current = null;
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +224 to +226
* 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: 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."

Comment on lines +659 to +660
// nor waits for a tap verdict. A show() from a capture handler of this
// same press ran just before this listener.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: 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.
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 43ce1f1

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: the 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.

@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 20:15
@cixzhang
cixzhang merged commit 61cf773 into main Nov 4, 2026
188 of 191 checks passed
cixzhang added a commit that referenced this pull request Nov 4, 2026
…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]>
@github-actions
github-actions Bot deleted the lane4/infotip-use-tooltip branch November 4, 2026 06:04
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 4, 2026
…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.
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 5, 2026
…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.

This branch was successfully deployed

1 active deployment
Preview — 43ce1f1d Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant