Repository navigation
fix(Tooltip): under focusTrigger="auto", decide when focus arrives whether it opens the tooltip - #9366
Conversation
…ether it opens the tooltip Tooltip FR4: under auto, focus opens the tooltip on any focusable trigger. The hook decided once, when it attached its listeners, from the trigger's tabindex then. A roving-tabindex member that was tabindex="-1" at that moment (a Toolbar or ButtonGroup Button whose tooltip was set after mount, or a caller's roving group) never opened on keyboard focus, and a focusable trigger the check did not list, such as a <summary>, never did either. The focus listeners now attach unless focusTrigger is never, and auto decides per event: focus on the trigger itself counts, and focus inside it counts while the trigger is focusable. A plain wrapper still ignores its children's focus, and their blur does not hide a hover-opened tooltip. FR4 drops both auto gaps and the matching Current-state impact bullet.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Changes requested: the per-event auto check fixes the roving-tabindex case from #9359, and the new tests fail on main and pass here, but it adds one focus-leave regression and leaves four lines describing the old behavior.
handleFocusOutre-checks the trigger's focusability at blur, so when a container trigger leaves the tab order while one of its children holds focus, the tooltip never hides. Record inhandleFocusInwhether the focus counted, honor that inhandleFocusOut, and add a test for it.- Update
useTooltip.doc.mjs:52(the dense doc still says "naturally focusable elements only"),Tooltip.spec.md:49(nine further gaps now, not ten),:191(drop "(FR4's gap)") and:305-307(the newautocases now have focused tests, so they leave the untested list).
[Automated review]
| const handleFocusOut = useCallback( | ||
| (e: Event) => { | ||
| if (!isFocusForTrigger(e)) { | ||
| return; | ||
| } | ||
| scheduleHide(); | ||
| }, | ||
| [isFocusForTrigger, scheduleHide], | ||
| ); |
There was a problem hiding this comment.
This re-judges the blur against the trigger's focusability now, not against whether the matching focusin counted. If a focusable container trigger leaves the tab order while one of its children holds focus (useListFocus resets every tabindex before calling focus()), the blur is ignored and the tooltip stays open, contrary to FR4's "Focus leaving the trigger schedules the hide". The base always hid it. One way to fix it:
const focusCountedRef = useRef(false);
// first line of handleFocusIn:
focusCountedRef.current = isFocusForTrigger(e);
// handleFocusOut:
if (!focusCountedRef.current && !isFocusForTrigger(e)) {
return;
}
focusCountedRef.current = false;
scheduleHide();| - FR4: `focusTrigger="always"`, `"never"`, and `"auto"` judged when focus | ||
| arrives (a roving member that was `tabindex="-1"`, a `<summary>`, and a | ||
| non-focusable wrapper whose child takes focus), |
There was a problem hiding this comment.
These three auto cases now have focused tests in useTooltip.test.tsx, so they no longer belong under "Read from source, with no focused test yet". Keep always and never here and drop the "auto" clause. In the same record, line 49 still counts "ten further implementation gaps" (nine remain beyond press-to-pin), and line 191 still points at "(FR4's gap)" for auto.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Markdown | 149.3 kB (+92 B) · 18.2 kB CSS (0) | — | — · — · — |
| Field | 46.5 kB (+82 B) · 8.3 kB CSS (0) | — | — · — · — |
| Switch | 51.6 kB (+79 B) · 9.7 kB CSS (0) | — | — · — · — |
107 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| CheckboxInput | 53.3 kB (+78 B) · 9.7 kB CSS (0) | — | — · — · — |
| RadioList | 48.0 kB (+76 B) · 8.3 kB CSS (0) | — | — · — · — |
| lab/CommentPin | 50.8 kB (+75 B) · 1.2 kB CSS (0) | — | — · — · — |
| InputGroup | 47.1 kB (+74 B) · 8.4 kB CSS (0) | — | — · — · — |
| ContextMenu | 78.9 kB (+72 B) · 15.3 kB CSS (0) | — | — · — · — |
| TextArea | 51.8 kB (+72 B) · 9.8 kB CSS (0) | — | — · — · — |
| CheckboxList | 48.4 kB (+71 B) · 8.6 kB CSS (0) | — | — · — · — |
| DateTimeInput | 115.8 kB (+71 B) · 15.6 kB CSS (0) | — | — · — · — |
| DateInput | 104.0 kB (+70 B) · 15.2 kB CSS (0) | — | — · — · — |
| SideNavHeading | 62.0 kB (+70 B) · 10.6 kB CSS (0) | — | — · — · — |
| TableCell | 80.1 kB (+70 B) · 15.7 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 79.8 kB (+70 B) · 15.5 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 217.5 kB (+69 B) · 454 B CSS (0) | — | — · — · — |
| AvatarGroup | 42.0 kB (+68 B) · 6.6 kB CSS (0) | — | — · — · — |
| Table | 88.8 kB (+68 B) · 16.0 kB CSS (0) | — | — · — · — |
| AvatarGroupOverflow | 42.7 kB (+66 B) · 6.5 kB CSS (0) | — | — · — · — |
| Pagination | 89.5 kB (+66 B) · 15.8 kB CSS (0) | — | — · — · — |
| lab/TransferList | 70.8 kB (+65 B) · 1.7 kB CSS (0) | — | — · — · — |
| Avatar | 39.3 kB (+64 B) · 6.5 kB CSS (0) | — | — · — · — |
| lab/ListInput | 78.7 kB (+64 B) · 1.6 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 76.4 kB (+64 B) · 1.9 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 57.9 kB (+63 B) · 11.0 kB CSS (0) | — | — · — · — |
| SegmentedControl | 41.0 kB (+63 B) · 6.5 kB CSS (0) | — | — · — · — |
| SideNavItem | 58.2 kB (+63 B) · 10.4 kB CSS (0) | — | — · — · — |
| DateRangeInput | 73.2 kB (+62 B) · 11.6 kB CSS (0) | — | — · — · — |
| Selector | 80.9 kB (+62 B) · 15.5 kB CSS (0) | — | — · — · — |
| Tooltip · Storybook | 18.0 kB (+62 B) · 5.0 kB CSS (0) | 604 (+24) | ✓ · ✓ · ✓ |
| TopNavHeading | 61.4 kB (+62 B) · 10.4 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 69.4 kB (+62 B) · 1.1 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 71.2 kB (+61 B) · 11.4 kB CSS (0) | — | — · — · — |
| lab/MobileTokenizer | 96.6 kB (+61 B) · 880 B CSS (0) | — | — · — · — |
| lab/EmojiPicker | 66.7 kB (+60 B) · 722 B CSS (0) | — | — · — · — |
| StatusDot | 20.2 kB (+59 B) · 6.3 kB CSS (0) | — | — · — · — |
| TextInput | 57.0 kB (+58 B) · 10.9 kB CSS (0) | — | — · — · — |
| TopNavMenu | 61.4 kB (+58 B) · 10.5 kB CSS (0) | — | — · — · — |
| charts/Chart | 67.4 kB (+57 B) · 20 B CSS (0) | — | — · — · — |
| BaseTypeahead | 58.8 kB (+57 B) · 10.3 kB CSS (0) | — | — · — · — |
| MultiSelector | 76.8 kB (+57 B) · 15.1 kB CSS (0) | — | — · — · — |
| TimeInput | 92.4 kB (+57 B) · 14.1 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 57.8 kB (+57 B) · 11.2 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 68.9 kB (+57 B) · 773 B CSS (0) | — | — · — · — |
| ListItem | 57.3 kB (+56 B) · 11.0 kB CSS (0) | — | — · — · — |
| RadioListItem | 55.8 kB (+56 B) · 10.1 kB CSS (0) | — | — · — · — |
| Thumbnail | 53.9 kB (+56 B) · 11.3 kB CSS (0) | — | — · — · — |
| Link | 46.7 kB (+55 B) · 7.9 kB CSS (0) | — | — · — · — |
| Popover | 52.8 kB (+55 B) · 12.4 kB CSS (0) | — | — · — · — |
| ChatComposer | 65.2 kB (+54 B) · 11.2 kB CSS (0) | — | — · — · — |
| DialogHeader | 52.0 kB (+54 B) · 10.2 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 55.7 kB (+54 B) · 11.5 kB CSS (0) | — | — · — · — |
| Carousel | 53.6 kB (+53 B) · 10.5 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 59.8 kB (+53 B) · 10.4 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 59.8 kB (+53 B) · 10.4 kB CSS (0) | — | — · — · — |
| TabMenu | 58.7 kB (+53 B) · 10.4 kB CSS (0) | — | — · — · — |
| NumberInput | 59.2 kB (+52 B) · 11.1 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 273.3 kB (+52 B) · 2.6 kB CSS (0) | — | — · — · — |
| FileInput | 57.8 kB (+51 B) · 10.7 kB CSS (0) | — | — · — · — |
| Typeahead | 66.5 kB (+51 B) · 11.7 kB CSS (0) | — | — · — · — |
| AlertDialog | 60.0 kB (+50 B) · 12.7 kB CSS (0) | — | — · — · — |
| Calendar | 58.3 kB (+50 B) · 10.3 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 253.8 kB (+50 B) · 2.3 kB CSS (0) | — | — · — · — |
| Button | 46.2 kB (+49 B) · 9.5 kB CSS (0) | — | — · — · — |
| IconButton | 46.2 kB (+49 B) · 9.5 kB CSS (0) | — | — · — · — |
| Stepper | 50.6 kB (+49 B) · 9.9 kB CSS (0) | — | — · — · — |
| CodeBlock | 63.5 kB (+48 B) · 11.1 kB CSS (0) | — | — · — · — |
| lab/TourStep | 58.2 kB (+48 B) · 590 B CSS (0) | — | — · — · — |
| ChatSendButton | 48.9 kB (+47 B) · 9.5 kB CSS (0) | — | — · — · — |
| ToggleButton | 47.0 kB (+47 B) · 9.6 kB CSS (0) | — | — · — · — |
| Lightbox | 54.7 kB (+46 B) · 10.1 kB CSS (0) | — | — · — · — |
| Slider | 51.2 kB (+46 B) · 8.9 kB CSS (0) | — | — · — · — |
| Banner | 51.0 kB (+45 B) · 10.3 kB CSS (0) | — | — · — · — |
| ChatLayout | 52.1 kB (+45 B) · 10.3 kB CSS (0) | — | — · — · — |
| ComplexSelector | 59.8 kB (+45 B) · 11.0 kB CSS (0) | — | — · — · — |
| FieldLabel | 40.2 kB (+45 B) · 5.9 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 49.9 kB (+45 B) · 9.8 kB CSS (0) | — | — · — · — |
| Toast | 63.1 kB (+45 B) · 10.1 kB CSS (0) | — | — · — · — |
| Tokenizer | 73.6 kB (+44 B) · 17.0 kB CSS (0) | — | — · — · — |
| DrawerHeader | 52.1 kB (+43 B) · 11.6 kB CSS (0) | — | — · — · — |
| SideNav | 69.6 kB (+43 B) · 10.9 kB CSS (0) | — | — · — · — |
| lab/MobilePowerSearch | 161.0 kB (+43 B) · 1.2 kB CSS (0) | — | — · — · — |
| lab/Schedule | 64.2 kB (+43 B) · 3.9 kB CSS (0) | — | — · — · — |
| AppShell | 72.1 kB (+42 B) · 12.0 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 49.4 kB (+42 B) · 9.7 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 49.6 kB (+41 B) · 9.9 kB CSS (0) | — | — · — · — |
| DropdownMenu | 76.9 kB (+40 B) · 15.4 kB CSS (0) | — | — · — · — |
| LayerProvider | 67.2 kB (+40 B) · 10.5 kB CSS (0) | — | — · — · — |
| MobileNav | 54.4 kB (+40 B) · 10.4 kB CSS (0) | — | — · — · — |
| PowerSearch | 176.3 kB (+40 B) · 20.4 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 222.1 kB (+40 B) · 2.4 kB CSS (0) | — | — · — · — |
| charts/ChartTooltip | 56.7 kB (+39 B) · 20 B CSS (0) | — | — · — · — |
| ChatDictationButton | 49.6 kB (+39 B) · 9.8 kB CSS (0) | — | — · — · — |
| charts/ChartLegend | 56.8 kB (+38 B) · 20 B CSS (0) | — | — · — · — |
| TopNav | 55.3 kB (+37 B) · 10.7 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 98.1 kB (+35 B) · 1.9 kB CSS (0) | — | — · — · — |
| MoreMenu | 77.1 kB (+32 B) · 15.4 kB CSS (0) | — | — · — · — |
| lab/InfoTip | 23.1 kB (+32 B) · 458 B CSS (0) | — | — · — · — |
| lab/Comments | 226.8 kB (+30 B) · 2.5 kB CSS (0) | — | — · — · — |
| Spinner | 25.7 kB (+1 B) · 6.7 kB CSS (0) | — | — · — · — |
| Timestamp | 28.4 kB (+1 B) · 9.9 kB CSS (0) | — | — · — · — |
| ChatMessageList | 29.9 kB (0) · 7.9 kB CSS (0) | — | — · — · — |
| CommandPalette | 54.1 kB (0) · 12.2 kB CSS (0) | — | — · — · — |
| CommandPaletteInput | 33.7 kB (0) · 8.5 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 62.1 kB (0) · 9.9 kB CSS (0) | — | — · — · — |
| Heading | 7.9 kB (0) · 6.0 kB CSS (0) | — | — · — · — |
| ProgressBar | 7.9 kB (0) · 6.9 kB CSS (0) | — | — · — · — |
| Text | 7.4 kB (0) · 6.0 kB CSS (0) | — | — · — · — |
| ChatToolCalls | 33.0 kB (−1 B) · 9.3 kB CSS (0) | — | — · — · — |
| Timer | 9.5 kB (−1 B) · 7.0 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 5.69 MB packed (+668 B); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: core 1 row; 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
…val; records say what auto does CodeBunny on #9366: the blur was judged against the trigger's focusability at blur time, so a focusable container that left the tab order while a child held focus kept a focus-opened tooltip open. The handler now remembers whether the arriving focus counted and hides on its blur either way. The record's summary gap count, the Focus trigger concept row, the "no focused test yet" list, the verification row and the hook doc no longer describe the old attach-time check.
There was a problem hiding this comment.
Recommend approval: the per-event auto check fixes the roving Toolbar and ButtonGroup case from #9359, the blur now hides whatever focus opened, and the new tests fail without the change and pass with it. The earlier focus-leave regression and the four stale documentation lines are fixed. Before merging, rebase onto main: the branch conflicts in Tooltip.spec.md, where FR11 re-padded the requirement table, and at the end of Tooltip.test.tsx.
[Automated review]
|
/approve-spec 44ded5d |
…s-roving # Conflicts: # docs/specs/components/Tooltip/Tooltip.spec.md # packages/core/src/Tooltip/Tooltip.test.tsx
There was a problem hiding this comment.
Recommend approval: the per-event auto check fixes the roving Toolbar and ButtonGroup case from #9359, the blur still hides whatever focus opened, and the new tests fail without the change and pass with it. The merge from main keeps the FR11 rows and tests intact, and the record edit carries a spec approval for this head, so nothing further is needed from the review.
[Automated review]
|
/approve-spec 53888b4 |
Fixes #9359.
User impact
Keyboard users lost tooltips on roving-tabindex members. In a Toolbar or ButtonGroup, a Button or IconButton whose
tooltipwas set after mount (for example, "Show shortcut hints" turned on) never showed its tooltip when the arrow keys reached it. It showed only on mouse hover. The same happened in any caller's roving group that renderstabIndex={-1}, from the first render. A focusable trigger the old check didn't list, such as a<summary>, never opened on keyboard focus either.Now, under the default
focusTrigger="auto", those triggers open on keyboard focus like every other trigger.Problem and solution fit
useTooltipdecided once, when it attached its listeners, whether focus counted:focusTrigger === 'always' || (focusTrigger === 'auto' && isFocusable(el)).isFocusableis false fortabindex="-1", and the decision wasn't revisited when the roving hook later moved the tab stop onto the element.focusTriggerisnever, andautodecides per event. Focus on the trigger itself counts, since a trigger that receives focus is focusable by definition. Focus inside the trigger counts while the trigger is focusable, which is what the old attach-time check allowed.tabindexbefore moving focus).alwaysandneverbehave as before. The:focus-visible, touch and modality checks in the focus handler are untouched.Current specification
component:TooltipFR4: "UnderfocusTrigger="auto", focus opens the tooltip on any focusable trigger." The record listed two implementation gaps against that sentence: the tab order read only at attach time, and the narrow list of recognized triggers. Both now hold. This PR:The
focusTriggerdocs (Tooltip prop JSDoc anduseTooltip.doc.mjs) now describe whatautodoes.Writing rubric results
Evidence
main, green here:useTooltip.test.tsx: a trigger that wastabindex="-1"when the tooltip attached opens on keyboard focus after the roving hook moves the stop to it;useTooltip.test.tsx: a<summary>trigger opens on keyboard focus;Tooltip.test.tsx: the issue's repro. A real Toolbar has two IconButtons, the second'stooltipis turned on after mount, and ArrowRight from the first opens the second's tooltip.tscfor core: clean.pnpm check:knowledge: aligned.LOC
+233 / −33: about 45 product lines and about 165 test lines.
Scope
focusTrigger="auto"judges focus when it arrives.autogaps and the matching Current-state impact bullet removed.