Repository navigation
fix(useFocusTrap): Tab stops inside a closed dialog the page displays - #11892
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 | 4.4 kB (0) · 20 B CSS (0) | — | ✓ · ✓ · ✗ |
| CommandPalette | 77.9 kB (+71 B) · 12.7 kB CSS (0) | — | — · — · — |
| charts/ChartLegend | 40.2 kB (+60 B) · 224 B CSS (0) | — | — · — · — |
148 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| PowerSearch | 306.8 kB (+58 B) · 25.5 kB CSS (0) | — | — · — · — |
| ContextMenuItem | 35.4 kB (+53 B) · 7.1 kB CSS (0) | — | — · — · — |
| Carousel | 74.7 kB (+51 B) · 11.7 kB CSS (0) | — | — · — · — |
| DateInput | 200.0 kB (+51 B) · 17.9 kB CSS (0) | — | — · — · — |
| AlertDialog | 128.7 kB (+49 B) · 15.4 kB CSS (0) | — | — · — · — |
| Popover | 98.6 kB (+49 B) · 15.1 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 173.6 kB (+47 B) · 1.9 kB CSS (0) | — | — · — · — |
| Text | 11.0 kB (+46 B) · 5.5 kB CSS (0) | — | — · — · — |
| MultiSelector | 101.4 kB (+45 B) · 17.7 kB CSS (0) | — | — · — · — |
| SideNavHeading | 82.5 kB (+45 B) · 12.1 kB CSS (0) | — | — · — · — |
| Selector | 112.8 kB (+44 B) · 18.6 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 114.8 kB (+44 B) · 1.1 kB CSS (0) | — | — · — · — |
| lab/TourStep | 93.2 kB (+44 B) · 691 B CSS (0) | — | — · — · — |
| AppShell | 97.6 kB (+41 B) · 14.3 kB CSS (0) | — | — · — · — |
| Timestamp | 27.0 kB (+41 B) · 11.0 kB CSS (0) | — | — · — · — |
| TopNav | 78.0 kB (+41 B) · 11.7 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 362.9 kB (+41 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 121.1 kB (+41 B) · 1.4 kB CSS (0) | — | — · — · — |
| DateTimeInput | 223.5 kB (+40 B) · 19.7 kB CSS (0) | — | — · — · — |
| Pagination | 123.8 kB (+40 B) · 19.0 kB CSS (0) | — | — · — · — |
| lab/Comments | 369.8 kB (+40 B) · 2.5 kB CSS (0) | — | — · — · — |
| lab/LineClamp | 13.5 kB (+39 B) · 168 B CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 299.6 kB (+38 B) · 454 B CSS (0) | — | — · — · — |
| ChatToolCalls | 31.6 kB (+37 B) · 8.4 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 113.6 kB (+37 B) · 773 B CSS (0) | — | — · — · — |
| Spinner | 24.0 kB (+36 B) · 6.3 kB CSS (0) | — | — · — · — |
| Lightbox | 145.9 kB (+35 B) · 11.9 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 76.1 kB (+35 B) · 12.6 kB CSS (0) | — | — · — · — |
| Table | 120.2 kB (+34 B) · 19.6 kB CSS (0) | — | — · — · — |
| Timer | 13.1 kB (+34 B) · 6.1 kB CSS (0) | — | — · — · — |
| lab/Schedule | 114.6 kB (+34 B) · 3.9 kB CSS (0) | — | — · — · — |
| CommandPaletteInput | 32.9 kB (+33 B) · 7.6 kB CSS (0) | — | — · — · — |
| ChatMessageList | 27.4 kB (+31 B) · 7.1 kB CSS (0) | — | — · — · — |
| SideNav | 121.2 kB (+31 B) · 12.2 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 65.6 kB (+30 B) · 10.8 kB CSS (0) | — | — · — · — |
| charts/Chart | 237.9 kB (+28 B) · 516 B CSS (0) | — | — · — · — |
| CodeBlock | 80.1 kB (+28 B) · 12.1 kB CSS (0) | — | — · — · — |
| Heading | 11.6 kB (+28 B) · 5.5 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 96.9 kB (+27 B) · 13.3 kB CSS (0) | — | — · — · — |
| Link | 56.4 kB (+27 B) · 7.1 kB CSS (0) | — | — · — · — |
| Markdown | 202.7 kB (+27 B) · 21.9 kB CSS (0) | — | — · — · — |
| MobileNav | 76.3 kB (+27 B) · 11.4 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 103.0 kB (+27 B) · 18.9 kB CSS (0) | — | — · — · — |
| TabMenu | 78.9 kB (+27 B) · 11.9 kB CSS (0) | — | — · — · — |
| TopNavHeading | 82.1 kB (+25 B) · 12.0 kB CSS (0) | — | — · — · — |
| BottomSheet | 73.0 kB (+24 B) · 7.7 kB CSS (0) | — | — · — · — |
| Stepper | 66.7 kB (+24 B) · 10.9 kB CSS (0) | — | — · — · — |
| lab/DialogHeroHeader | 88.6 kB (+24 B) · 372 B CSS (0) | — | — · — · — |
| ListItem | 79.1 kB (+23 B) · 12.0 kB CSS (0) | — | — · — · — |
| lab/TabBarMoreList | 102.0 kB (+23 B) · 1.8 kB CSS (0) | — | — · — · — |
| InfoTip | 50.4 kB (+22 B) · 5.4 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 65.9 kB (+22 B) · 10.8 kB CSS (0) | — | — · — · — |
| lab/SelectableCardGroup | 68.8 kB (+22 B) · 162 B CSS (0) | — | — · — · — |
| DrawerHeader | 68.0 kB (+21 B) · 13.7 kB CSS (0) | — | — · — · — |
| TableCell | 103.3 kB (+21 B) · 19.1 kB CSS (0) | — | — · — · — |
| TextInput | 72.7 kB (+21 B) · 12.0 kB CSS (0) | — | — · — · — |
| TopNavMenu | 81.5 kB (+21 B) · 12.0 kB CSS (0) | — | — · — · — |
| IconButton | 65.0 kB (+20 B) · 10.8 kB CSS (0) | — | — · — · — |
| TimeInput | 174.8 kB (+20 B) · 16.9 kB CSS (0) | — | — · — · — |
| Toolbar | 47.1 kB (+20 B) · 8.1 kB CSS (0) | — | — · — · — |
| charts/ChartTooltip | 215.0 kB (+19 B) · 451 B CSS (0) | — | — · — · — |
| MobileNavToggle | 65.3 kB (+19 B) · 10.8 kB CSS (0) | — | — · — · — |
| RadioListItem | 76.1 kB (+19 B) · 10.7 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 305.6 kB (+19 B) · 2.6 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 65.6 kB (+18 B) · 11.0 kB CSS (0) | — | — · — · — |
| lab/TransferList | 112.1 kB (+18 B) · 1.2 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 282.1 kB (+18 B) · 2.3 kB CSS (0) | — | — · — · — |
| Banner | 67.0 kB (+17 B) · 11.3 kB CSS (0) | — | — · — · — |
| ChatComposer | 84.6 kB (+17 B) · 12.9 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 75.2 kB (+17 B) · 14.0 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 78.4 kB (+16 B) · 11.7 kB CSS (0) | — | — · — · — |
| Drawer | 54.0 kB (+16 B) · 8.4 kB CSS (0) | — | — · — · — |
| Thumbnail | 69.4 kB (+16 B) · 12.3 kB CSS (0) | — | — · — · — |
| ChatSendButton | 65.4 kB (+15 B) · 10.8 kB CSS (0) | — | — · — · — |
| ComplexSelector | 77.6 kB (+15 B) · 12.6 kB CSS (0) | — | — · — · — |
| DialogHeader | 67.9 kB (+15 B) · 12.3 kB CSS (0) | — | — · — · — |
| TabList | 47.3 kB (+15 B) · 6.5 kB CSS (0) | — | — · — · — |
| Typeahead | 87.9 kB (+15 B) · 13.5 kB CSS (0) | — | — · — · — |
| DateRangeInput | 99.3 kB (+14 B) · 13.3 kB CSS (0) | — | — · — · — |
| Calendar | 76.1 kB (+13 B) · 11.4 kB CSS (0) | — | — · — · — |
| CheckboxList | 73.1 kB (+13 B) · 7.8 kB CSS (0) | — | — · — · — |
| Dialog | 25.5 kB (+13 B) · 6.9 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 82.2 kB (+12 B) · 12.1 kB CSS (0) | — | — · — · — |
| Slider | 114.5 kB (+12 B) · 8.9 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 78.5 kB (+11 B) · 10.4 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 92.4 kB (+11 B) · 751 B CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 82.2 kB (+10 B) · 12.1 kB CSS (0) | — | — · — · — |
| ContextMenu | 102.0 kB (+10 B) · 18.7 kB CSS (0) | — | — · — · — |
| DropdownMenu | 107.4 kB (+10 B) · 18.8 kB CSS (0) | — | — · — · — |
| FieldLabel | 55.4 kB (+10 B) · 5.8 kB CSS (0) | — | — · — · — |
| AvatarGroupOverflow | 51.9 kB (+9 B) · 5.7 kB CSS (0) | — | — · — · — |
| Button | 65.0 kB (+9 B) · 10.8 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 79.9 kB (+9 B) · 12.0 kB CSS (0) | — | — · — · — |
| MoreMenu | 107.6 kB (+9 B) · 18.8 kB CSS (0) | — | — · — · — |
| FileInput | 74.1 kB (+8 B) · 11.7 kB CSS (0) | — | — · — · — |
| RadioList | 60.8 kB (+8 B) · 7.3 kB CSS (0) | — | — · — · — |
| TextArea | 66.8 kB (+8 B) · 9.4 kB CSS (0) | — | — · — · — |
| AvatarGroup | 48.7 kB (+6 B) · 5.8 kB CSS (0) | — | — · — · — |
| HoverCard | 30.2 kB (+6 B) · 4.5 kB CSS (0) | — | — · — · — |
| InputGroup | 61.0 kB (+6 B) · 7.9 kB CSS (0) | — | — · — · — |
| Tokenizer | 104.3 kB (+6 B) · 20.3 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 93.2 kB (+6 B) · 2.1 kB CSS (0) | — | — · — · — |
| NumberInput | 77.5 kB (+4 B) · 12.2 kB CSS (0) | — | — · — · — |
| Field | 59.4 kB (+3 B) · 7.3 kB CSS (0) | — | — · — · — |
| SelectorOption | 24.0 kB (+2 B) · 6.7 kB CSS (0) | — | — · — · — |
| Collapsible | 29.0 kB (+1 B) · 4.5 kB CSS (0) | — | — · — · — |
| DropdownMenuCheckboxItem | 28.6 kB (+1 B) · 7.3 kB CSS (0) | — | — · — · — |
| Item | 20.5 kB (+1 B) · 6.2 kB CSS (0) | — | — · — · — |
| SideNavItem | 76.9 kB (+1 B) · 11.9 kB CSS (0) | — | — · — · — |
| ToggleButton | 92.0 kB (+1 B) · 10.9 kB CSS (0) | — | — · — · — |
| lab/ChatVirtualizer | 57.2 kB (+1 B) · 223 B CSS (0) | — | — · — · — |
| BottomSheetSwitcher | 18.7 kB (0) · 3.4 kB CSS (0) | — | — · — · — |
| ButtonGroup | 44.1 kB (0) · 3.7 kB CSS (0) | — | — · — · — |
| ClickableCard | 18.5 kB (0) · 7.3 kB CSS (0) | — | — · — · — |
| CommandPaletteItem | 13.4 kB (0) · 3.6 kB CSS (0) | — | — · — · — |
| DropdownMenuRadioItem | 28.6 kB (0) · 7.3 kB CSS (0) | — | — · — · — |
| LayoutPanel | 22.0 kB (0) · 4.9 kB CSS (0) | — | — · — · — |
| NavHeadingMenu | 18.5 kB (0) · 3.5 kB CSS (0) | — | — · — · — |
| ProgressBar | 11.9 kB (0) · 6.4 kB CSS (0) | — | — · — · — |
| ResizeHandle | 22.3 kB (0) · 4.3 kB CSS (0) | — | — · — · — |
| SegmentedControlItem | 18.8 kB (0) · 4.3 kB CSS (0) | — | — · — · — |
| SelectableCard | 18.7 kB (0) · 7.5 kB CSS (0) | — | — · — · — |
| Step | 31.6 kB (0) · 5.6 kB CSS (0) | — | — · — · — |
| Tab | 14.9 kB (0) · 4.2 kB CSS (0) | — | — · — · — |
| Toast | 103.6 kB (0) · 11.1 kB CSS (0) | — | — · — · — |
| Token | 29.5 kB (0) · 4.9 kB CSS (0) | — | — · — · — |
| TopNavItem | 14.5 kB (0) · 4.0 kB CSS (0) | — | — · — · — |
| TreeList | 46.2 kB (0) · 5.9 kB CSS (0) | — | — · — · — |
| lab/NavigationScreen | 84.9 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/NavigationStack | 84.9 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/PageControl | 78.2 kB (0) · 709 B CSS (0) | — | — · — · — |
| lab/TabBar | 83.5 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
| lab/TabBarItem | 3.9 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
| CheckboxInput | 69.0 kB (−1 B) · 10.1 kB CSS (0) | — | — · — · — |
| Outline | 25.3 kB (−1 B) · 4.1 kB CSS (0) | — | — · — · — |
| Switch | 108.9 kB (−1 B) · 10.0 kB CSS (0) | — | — · — · — |
| ToggleButtonGroup | 41.3 kB (−1 B) · 3.7 kB CSS (0) | — | — · — · — |
| DropdownMenuItem | 27.8 kB (−2 B) · 6.9 kB CSS (0) | — | — · — · — |
| TopNavMegaMenuItem | 14.3 kB (−2 B) · 4.2 kB CSS (0) | — | — · — · — |
| ChatLayout | 88.3 kB (−3 B) · 11.3 kB CSS (0) | — | — · — · — |
| SegmentedControl | 102.1 kB (−4 B) · 6.9 kB CSS (0) | — | — · — · — |
| Tooltip | 32.1 kB (−4 B) · 4.5 kB CSS (0) | — | — · — · — |
| Avatar | 45.9 kB (−5 B) · 5.7 kB CSS (0) | — | — · — · — |
| StatusDot | 33.8 kB (−5 B) · 5.4 kB CSS (0) | — | — · — · — |
| lab/CommentPin | 60.3 kB (−13 B) · 1.2 kB CSS (0) | — | — · — · — |
| lab/ListInput | 93.5 kB (−13 B) · 922 B CSS (0) | — | — · — · — |
| layer | — | — | — · ✓ · — |
| Layer | — | — | ✓ · ✓ · — |
Package size: @astryxdesign/core 7.61 MB packed (+504 B); no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
The focus trap counted every control inside a closed <dialog> as hidden. A Popover or DropdownMenu that opens inside a closed dialog the page displays in flow then had no Tab stops: the trap cancelled every Tab and Shift+Tab inside it, and a DropdownMenu's header and footer were no Tab stops. A closed dialog that the page displays has a box, so its controls are Tab stops now. A closed dialog with display: none has no box, and its controls stay out of the Tab cycle. utils/nodeType.ts, the DOM checks both modules already import, holds the closed-dialog checks. The layer runtime's anchor test reads them too.
There was a problem hiding this comment.
Changes requested: the Tab fix works and matches the Popover and DropdownMenu focus rules, but it adds a shared internal module that no current record defines.
packages/core/src/utils/dialogDisplay.tsis a new internal module imported by bothLayer/useLayer.tsxandhooks/useFocusTrap.tsthat no current record names (architecture:knowledge-contractsDEC-22), so either an engineering owner names it in a record with its usage, why it is needed and why the existing private helpers are not enough, or the box rule stays a private helper inuseFocusTrap.tsand the behaviour-neutraluseLayer.tsxrefactor is dropped.
The new unit case fails on the base and passes on this head, and in Chromium the new story's Popover and DropdownMenu go from focus stuck on the first field to a Tab walk that wraps. CI has not run on this head yet.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: Tab moves through a Popover or DropdownMenu that opens in a closed dialog the page displays: verified (browser check of the new story at this head).
- Claim: Tab and Shift+Tab wrap at the layer's edges: verified (Shift+Tab from the first field reaches the Close control; Tab past the footer returns to the header field).
- Claim: a DropdownMenu's header and footer are Tab stops again: verified (they were stops before the closed-dialog check was added; on the base they are skipped).
- Claim: the trap counted every control in a closed dialog as hidden and held focus: verified (
useFocusTrap.tsreachability test on the base and its zero-stop branch at lines 424-431). - Claim: a displayed closed dialog's controls are stops, a
display: noneone's are not: verified (dialogDisplay.ts:36-38, both unit cases, the hidden field in the story is skipped). - Claim: the anchor test keeps its behaviour: verified (
useLayer.tsx:865and:879evaluate the same expressions; Layer suites pass). - Claim: the old check fails the new unit case and browser cases: unit case verified on the base; the browser failure reproduced on base code, the spec itself not run here.
- Claim: reproduction in WebKit: not checked here.
- Claim: owners ruled this a records-based repair with a layer-runtime clause to follow: not verifiable from the repository or this pull request.
- Claim: no public API change: verified (built surface identical for Core, build and the seven themes).
- File
.changeset/focus-trap-closed-dialog-in-flow.md: clear. - File
apps/storybook/stories/LayerDismissal.stories.tsx: clear. - File
packages/core/src/Layer/useLayer.tsx: clear apart from importing the new module. - File
packages/core/src/hooks/__tests__/focusInClosedDialog.a11y.browser.spec.ts: clear. - File
packages/core/src/hooks/useFocusTrap.test.tsx: clear. - File
packages/core/src/hooks/useFocusTrap.ts: clear. - File
packages/core/src/utils/dialogDisplay.ts: blocking finding above.
5fc3a46 to
a92c1e9
Compare
|
/approve-spec a92c1e9 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, and it starts once the pull request is marked ready for review.
The Tab walk now matches the Popover and DropdownMenu focus rules for layers inside a closed dialog the page displays, and moving the checks into the existing utils/nodeType.ts resolves the earlier request about a new internal module.
- Non-blocking: the JSDoc of
isDialogShown(packages/core/src/utils/nodeType.ts:62-65) calls an open dialog "in the top layer", but a dialog opened withshow()or theopenattribute is open without being in the top layer; "Whetherdialogis shown: open, or shown as a popover" keeps the helper honest.
Claims and files checked
Review mode: full; reason: history
- Claim: Tab moves through a Popover or DropdownMenu that opens inside a closed dialog the page displays: verified (the new Chromium spec passes 3 of 3 at this head; key-by-key probes of the new story).
- Claim: Tab and Shift+Tab wrap at the layer's edges: verified (Shift+Tab before the first field reaches the close control; Tab past the footer returns to the header field).
- Claim: a DropdownMenu's header and footer are Tab stops again: verified (stops at this head, skipped on the base code; they were stops in releases before the closed-dialog check was added).
- Claim: the trap counted every control in a closed dialog as hidden, found no stops and held focus: verified (the base reachability loop and the zero-stop branch at
useFocusTrap.ts:427-434). - Claim: a displayed closed dialog's controls are stops and a
display: noneone's are not: verified (nodeType.ts:75-77, both unit cases, and the story's hidden field is skipped). - Claim: the checks live in
utils/nodeType.ts, already imported by both modules, and the anchor test keeps its behavior: verified (useLayer.tsx:864and:878evaluate the same expression; Layer suites pass). - Claim: the closed-dialog case reproduces before the change: verified in Chromium (spec cases 1 and 3 fail on the base code); WebKit not checked here.
- Claim: the same Popover in an open Dialog wraps before and after: verified (spec case 2 passes on both).
- Claim: the old check fails the new unit case and the closed-dialog browser cases: verified (the unit case fails 1 of 47 on the base code; Chromium cases 1 and 3 fail).
- Claim: red first, Chromium fails 2 of 3 and WebKit 1 of 2; green, Chromium 3 of 3 and WebKit 2 of 2: Chromium verified; WebKit not checked here.
- Claim: the owners ruled this a defect repair and a separate pull request adds the layer-runtime clause: not verifiable from the repository; an engineering owner commented
/approve-specfor this exact head, and the clause pull request is still open. - Claim: no public API change, and no package entry re-exports the new helpers: verified (built surface identical for Core, build and the seven themes; no entry re-exports
nodeType.ts). - Claim: +298/−34 lines: verified. Bundle and reference-page gzip deltas: not re-measured here.
- Claim: the useLayer, useFocusTrap and nodeType unit suites pass: verified (those suites and every other focus-trap user's suite pass at this head).
- Claim: the full unit suite, CI's accessibility selection and the interaction specs are still running: status only; CI has not run at this head.
- File
.changeset/focus-trap-closed-dialog-in-flow.md: clear. - File
apps/storybook/stories/LayerDismissal.stories.tsx: clear. - File
packages/core/src/Layer/useLayer.tsx: clear. - File
packages/core/src/hooks/__tests__/focusInClosedDialog.a11y.browser.spec.ts: clear. - File
packages/core/src/hooks/useFocusTrap.test.tsx: clear. - File
packages/core/src/hooks/useFocusTrap.ts: clear. - File
packages/core/src/utils/nodeType.ts: non-blocking JSDoc note above.
| * Whether `dialog` is in the top layer: open, or shown as a popover. A | ||
| * non-modal Drawer is shown with `showPopover()` and never sets `open`. |
There was a problem hiding this comment.
Non-blocking: a dialog opened with show() or the open attribute is open but not in the top layer, so "in the top layer" misdescribes this helper. Suggested wording:
/**
* Whether `dialog` is shown: open, or shown as a popover. A non-modal
* Drawer is shown with `showPopover()` and never sets `open`.
*/|
/approve-spec 040506a |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, and it starts once the pull request is marked ready for review.
The Tab walk matches the Popover and DropdownMenu focus rules for layers inside a closed dialog the page displays, and merging main left this pull request's own changes untouched.
- Non-blocking: the JSDoc of
isDialogShown(packages/core/src/utils/nodeType.ts:62-65) calls an open dialog "in the top layer", but a dialog opened withshow()or theopenattribute is open without being in the top layer; "Whetherdialogis shown: open, or shown as a popover" keeps the helper honest.
Claims and files checked
Review mode: carry-forward; reason: none
- Claim: Tab moves through a Popover or DropdownMenu that opens inside a closed dialog the page displays: verified (the new unit case passes at this head; the Chromium spec passed with this identical patch and failed on the base code).
- Claim: Tab and Shift+Tab wrap at the layer's edges: verified (the unit case wraps from the last stop to the first; in Chromium, Shift+Tab before the first field reaches the close control and Tab past the footer returns to the header field).
- Claim: a DropdownMenu's header and footer are Tab stops again: verified (stops with the fix and skipped on the base code in the Chromium spec; the region stops read the same reachability test).
- Claim: the trap counted every control in a closed dialog as hidden, found no stops and held focus: verified (the base reachability loop, and the zero-stop branch at
useFocusTrap.ts:427-434). - Claim: a displayed closed dialog's controls are stops and a
display: noneone's are not: verified (nodeType.ts:75-77, both unit cases, and the story's hidden field is skipped). - Claim: the checks live in
utils/nodeType.ts, which both modules already import, and the anchor test keeps its behavior: verified (useLayer.tsx:864and:878evaluate the same expression; the Layer suite passes). - Claim: an earlier pull request lets layers open on controls in such a dialog: verified (it is merged, and the layer-runtime record states it).
- Claim: the owners ruled this a defect repair, and a separate pull request adds the layer-runtime clause: an engineering owner commented
/approve-specfor this exact head; the clause pull request is still an open draft. - Claim: the closed-dialog case reproduces before the change in Chromium and WebKit: Chromium verified (spec cases 1 and 3 fail on the base code); WebKit not checked.
- Claim: the same Popover in an open Dialog wraps before and after: verified (spec case 2 passes on both).
- Claim: the old check fails the new unit case and the closed-dialog browser cases: verified.
- Claim: one defect, with no public API, default or interaction model hidden under the fix: verified (no exported surface changes, and no package entry re-exports
nodeType.ts). - Claim: +298/−34 lines, split into source, tests, stories and changeset: verified.
- Claim: 126 of 149 measured imports change by −13 to +71 B gzip, with the listed per-component deltas: verified against CI's size report for the same patch; the four reference-page deltas were not re-measured.
- Claim: red first and green counts in Chromium and WebKit: Chromium verified; WebKit not checked.
- Claim: the useLayer, useFocusTrap and nodeType suites pass 215 of 215: verified at this head.
- Claim: the full unit suite, the accessibility selection and the interaction specs pass as listed: not re-run; 159 test files of the focus trap's users pass at this head.
- Claim: ESLint, Prettier and typecheck pass: ESLint and Prettier verified on the changed files and Core's typecheck verified at this head; Storybook's typecheck reports no error in the changed story (its other errors come from packages left unbuilt here); the changeset check and the pre-review script were not re-run.
- Claim: the head merges main with this pull request's own lines unchanged: verified (its own patch is byte-identical, and the merge needed no conflict resolution).
- Claim: at this head the new browser spec and the anchor-readiness spec pass in Chromium and WebKit: not re-run here.
- File
.changeset/focus-trap-closed-dialog-in-flow.md: clear. - File
apps/storybook/stories/LayerDismissal.stories.tsx: clear. - File
packages/core/src/Layer/useLayer.tsx: clear. - File
packages/core/src/hooks/__tests__/focusInClosedDialog.a11y.browser.spec.ts: clear. - File
packages/core/src/hooks/useFocusTrap.test.tsx: clear. - File
packages/core/src/hooks/useFocusTrap.ts: clear. - File
packages/core/src/utils/nodeType.ts: non-blocking JSDoc note above.
User impact
A
Popoveror aDropdownMenuthat opens inside a native<dialog>that the page displays closed has no Tab stops. Tab and Shift+Tab inside it leave focus where it is. ADropdownMenu's header and footer are no Tab stops.Problem and solution fit
The focus trap finds its Tab stops through
getFocusableElements. That filter counts every control inside a closed<dialog>as hidden, because a closed dialog usually renders nothing.A closed dialog that the page displays in flow renders its content. The browser focuses those controls, and #11864 lets layers open on them.
The trap then finds no stops. It cancels every Tab and Shift+Tab inside the layer and keeps focus in place.
Expected behavior and authority
A layer that traps focus wraps Tab and Shift+Tab across its own focusable content. The owners ruled this a defect repair. #11894 adds the clause to
architecture:layer-runtime.Smallest restoration
display: nonestill hides its controls.utils/nodeType.ts, which the focus trap and the anchor test already import, holds the closed-dialog checks. The anchor test keeps its behavior.Evidence
Popover's first field leaves focus there, in Chromium and in WebKit.Popover's last stop, and Tab wraps back to its first field. In Chromium, aDropdownMenuwalks its header, menu and footer, and wraps.Popoverin an openDialogwraps the same way before and after.Scope
Components: useFocusTrap, Layer (Popover, DropdownMenu)
Public and internal API delta
None public. Internal:
getFocusableElementscounts the controls of a closed<dialog>that has a box.utils/nodeType.tsexportsisShownAsPopover,isDialogShownandisDisplayedWhileClosed, and no package entry re-exports them.Testing
At a92c1e9, on Storybook builds made at this head and stamped with
git rev-parse HEAD:useFocusTrap.tsat main's, Chromium fails 2 of the 3 cases and WebKit 1 of 2. The open-Dialogguard passes. TheDropdownMenucase runs in Chromium only, because WebKit's Tab skips buttons by default.DropdownMenucase skipped.useLayer,useFocusTrapandnodeTypesuites pass 215 of 215. The newuseFocusTrapcase fails with the old check.uiproject passes all 25,874 tests in 1,038 files. Itsnodeproject failed 97 tests in 38 CLI files.nodefails 20 tests in 13 files here and 83 in 33 at main 6115f11. The 2 files that fail only here pass alone, here and at main.check:changesetsandreview:pre(332 authored lines, 0 findings) pass. Typecheck passes in every package.anchorReadinesspass in Chromium (14) and in WebKit (13, 1 skipped), and the three unit suites pass 215 of 215.