Skip to content

fix(useFocusTrap): Tab stops inside a closed dialog the page displays - #11892

Merged
cixzhang merged 2 commits into
meta:mainfrom
vjeux:fix/focus-trap-closed-dialog-displayed
Nov 15, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
vjeux:fix/focus-trap-closed-dialog-displayed

Conversation

@vjeux

@vjeux vjeux commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A Popover or a DropdownMenu that 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. A DropdownMenu'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

  • A closed dialog that the page displays has a box, so its controls are Tab stops. A closed dialog with display: none still 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

  • Reproduction before the change: in a displayed closed dialog, Tab on a Popover's first field leaves focus there, in Chromium and in WebKit.
  • Result after the change: Shift+Tab wraps to the Popover's last stop, and Tab wraps back to its first field. In Chromium, a DropdownMenu walks its header, menu and footer, and wraps.
  • Representative unchanged path: the same Popover in an open Dialog wraps the same way before and after.
  • Regression test or other mutation-sensitive proof: with the old check, the new unit case and the closed-dialog browser cases fail.

Scope

Components: useFocusTrap, Layer (Popover, DropdownMenu)

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Public and internal API delta

None public. Internal: getFocusableElements counts the controls of a closed <dialog> that has a box. utils/nodeType.ts exports isShownAsPopover, isDialogShown and isDisplayedWhileClosed, and no package entry re-exports them.

  • Size: +298/−34 lines (6115f11..a92c1e9): source +40/−32, tests +155/−1, stories +94/−1, changeset +9. Of 149 measured imports, 126 change by −13 to +71 B gzip, with no CSS change. Dialog +13 B, Drawer +16, BottomSheet +24, BottomSheetSwitcher 0, Lightbox +35, MobileNav +27, SideNav +31. INV10 pages: docs +4 B, form −16, menu +19, table +34.

Testing

At a92c1e9, on Storybook builds made at this head and stamped with git rev-parse HEAD:

  • Red first. With only useFocusTrap.ts at main's, Chromium fails 2 of the 3 cases and WebKit 1 of 2. The open-Dialog guard passes. The DropdownMenu case runs in Chromium only, because WebKit's Tab skips buttons by default.
  • Green. Chromium passes 3 of 3, and WebKit 2 of 2, with the DropdownMenu case skipped.
  • Units. The useLayer, useFocusTrap and nodeType suites pass 215 of 215. The new useFocusTrap case fails with the old check.
  • The full unit suite. Its ui project passes all 25,874 tests in 1,038 files. Its node project failed 97 tests in 38 CLI files.
  • Run alone, back to back on one box, node fails 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.
  • Accessibility selection. CI's selection picks 33 specs, and they pass in Chromium: 178 tests. Its 7 cross-browser specs pass in WebKit: 27 tests, with 1 skipped.
  • Interaction, Chromium. 35 specs of the focus trap's users pass: 391 tests, with 16 skipped. They cover Popover, DropdownMenu, Dialog, Drawer, BottomSheet, Lightbox, SideNav, Layer and the hooks.
  • Checks. ESLint with no warnings, Prettier, check:changesets and review:pre (332 authored lines, 0 findings) pass. Typecheck passes in every package.
  • After the main merge. 040506a merges main 344ec5b, with this pull request's own lines unchanged. At 040506a, this spec and anchorReadiness pass in Chromium (14) and in WebKit (13, 1 skipped), and the three unit suites pass 215 of 215.

@vercel

vercel Bot commented Nov 15, 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 15, 2026 6:00pm UTC

Request Review

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

astracat-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 15, 2026, 6:05 PM UTC

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 040506a

Storybook · Sandbox · built from this PR's head

Modified components

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.

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

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.ts is a new internal module imported by both Layer/useLayer.tsx and hooks/useFocusTrap.ts that no current record names (architecture:knowledge-contracts DEC-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 in useFocusTrap.ts and the behaviour-neutral useLayer.tsx refactor 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.ts reachability test on the base and its zero-stop branch at lines 424-431).
  • Claim: a displayed closed dialog's controls are stops, a display: none one'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:865 and :879 evaluate 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.

Automated review (maintainer link)

@vjeux
vjeux force-pushed the fix/focus-trap-closed-dialog-displayed branch from 5fc3a46 to a92c1e9 Compare November 15, 2026 16:46
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec a92c1e9

@cixzhang cixzhang added ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) labels Nov 15, 2026

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

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 with show() or the open attribute is open without being in the top layer; "Whether dialog is 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: none one'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:864 and :878 evaluate 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-spec for 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.

Automated review (maintainer link)

Comment on lines +63 to +64
* 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`.

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: 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`.
 */

@vjeux
vjeux marked this pull request as ready for review November 15, 2026 17:20
@vjeux
vjeux marked this pull request as draft November 15, 2026 17:37
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 040506a

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

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 with show() or the open attribute is open without being in the top layer; "Whether dialog is 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: none one'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:864 and :878 evaluate 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-spec for 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.

Automated review (maintainer link)

This branch was successfully deployed

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

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) 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.

2 participants