Skip to content

feat(DropdownMenu): header and footer hold controls beside the menu, never inside it - #7344

Merged
cixzhang merged 7 commits into
mainfrom
dropdown-menu-header-footer
Oct 11, 2026
Merged

cixzhang merged 7 commits into
mainfrom
dropdown-menu-header-footer

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

User impact

Products put a filter field or a "Create" button in a menu. Today the only place for one is among the rows, inside role="menu". To a screen reader that menu is invalid: it contains a textbox and a button that aren't menu items. The menu's key handling and press model then fight the control, because typing jumps to a matching row and a finger press is cancelled.

With header and footer, those controls sit in the same popover or sheet but outside the menu element. Screen-reader users get a valid menu, and the field and button work as they do anywhere else.

<DropdownMenu
  button={{label: 'Labels'}}
  header={<TextInput label="Filter labels" isLabelHidden value={query} onChange={setQuery} />}
  footer={<Button label="Create label" variant="ghost" onClick={createLabel} />}>
  {visible.map(label => <DropdownMenuItem key={label} label={label} onClick={() => pick(label)} />)}
</DropdownMenu>

Behavior

  • Structure: in the popover, the header comes first, then the role="menu" element, then the footer. The menu holds only its rows, and children remain rows only, so nothing can be placed between rows.
  • Keys and presses: a region keeps its own. The menu's key handling and press model are bound to the menu element, so they never claim an event that begins in a region.
  • Tab: the menu becomes one Tab stop between the regions. Tab walks header, menu, footer. Tab past the footer's last control, or Shift+Tab before the header's first, closes the menu and returns focus to the trigger, the same as Tab from the rows. If there's nothing to reach in that direction, Tab from the menu closes it as before.
  • Escape closes from anywhere in the popover. Focus on open is unchanged.
  • Bottom sheet: the header goes above the actions and the footer below them.
  • Height: the regions share the menu's block cap. The regions keep their height, and the rows shrink and scroll between them.
  • No props: without header or footer, the render is unchanged. A false or empty value renders no region.

No styling props are added for the regions. Callers style their own content, consistent with spec:AST-071.

Current specification

component:DropdownMenu (draft) gains the "Header and footer" concept row, FR15, its verification row, and DEC-8, decided by @cixzhang on 2026-10-11: controls beside the rows go in header and footer, and a menu holds only menu items. This replaces the hosted-control handling that #7338 removes (stacked on it), and it covers the case #7305 was built for.

Writing rubric results

  • R1 narration: none. FR15 and DEC-8 are in the present tense.
  • R2 research in the record: none.
  • R3 evidence naming a change: none. The FR15 verification row names the unit suite and the Chromium spec.
  • R4 rejected alternatives over one line or outside a decision: two, in one sentence inside DEC-8 (handlers stepping aside for controls among the rows; a caller-wrapped items element).
  • R5 pull request or issue references remaining: none in the record.
  • R6 ruled open questions still listing options: none.

Evidence

  • DropdownMenu.test.tsx, "header and footer" suite, 10 cases: regions sit outside the menu element and the menu holds only menuitems; the menu is a Tab stop; Tab from the menu defers to a region; Tab past the footer or before the header closes and returns focus; keys typed in a header field stay in it; a footer click acts with the menu open; no regions means unchanged behavior; false or empty values render no region; bottom-sheet order.
  • __tests__/MenuHeaderFooter.a11y.chromium.spec.ts against the new HeaderAndFooter story, in real Chromium: structure, typing filters without roving, the full Tab walk and close, Escape from the header, and a finger tap on the footer button.
  • DropdownMenu, ContextMenu, useMenuPress and doc-prop suites: 319 passed. Core and story type-checks clean; lint clean; check:knowledge aligned.

Scope

  • One capability is added.
  • Consumer docs, focused tests, a story and a changeset ship with it.
  • Public text and artifacts contain no internal Meta context.

@vercel

vercel Bot commented Oct 11, 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 Oct 11, 2026 10:48pm UTC

Request Review

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

astracat-bot Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 11, 2026, 11:18 PM UTC

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

42 of 450 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 238,081
Chat Full AI Chat probe dark 237,048
Markdown Default probe light 159,625
Markdown Default probe dark 158,986
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
TableRowExpansion Detail Panel neutral dark 5,129
TableRowExpansion Detail Panel neutral light 4,050

and 22 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang
cixzhang changed the base branch from revert-menu-hosted-controls to main October 11, 2026 18:46
…never inside it

A filter field or a Create button placed among a menu's rows makes the menu
invalid to a screen reader: role="menu" admits only menu items, groups and
separators. header and footer place such controls in the same popover or
sheet, outside the role="menu" element, so the menu holds only its rows and
never claims the controls' keys or presses.

With either region the menu is one Tab stop between them: Tab walks header,
menu, footer, and leaving past either end closes the menu and returns focus
to the trigger, as Tab from the rows always has. The bottom sheet shows the
header above the actions and the footer below. Without either prop nothing
changes.

Records the concept, FR15 and DEC-8 in component:DropdownMenu, with unit
tests, a HeaderAndFooter story and a real-Chromium keyboard and touch spec.
@cixzhang
cixzhang force-pushed the dropdown-menu-header-footer branch from a54d1f4 to 208a5bf Compare October 11, 2026 18:47
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 11, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 208a5bf

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

Thanks — this gives menus a valid place for controls beside their rows, but approval needs a maintainer to approve the proposed FR15, DEC-8 and “Header and footer” rows in component:DropdownMenu (still a draft) or to identify an existing current spec that admits header and footer. Whatever that decision, please fix these first:

  • Keyboard focus that lands on the menu element (Tab from the header, Shift+Tab from the footer or from a row) has no visible indicator, which misses WCAG 2.2 SC 2.4.7.
  • Shift+Tab from a focused row stops on the menu element before the header, so the menu is not yet the single Tab stop the PR describes.
  • The typing test in MenuHeaderFooter.a11y.chromium.spec.ts fails because only “Design” contains “de”, not “Documentation”.

[Automated review]

// An overflowing menu joins the Tab order so its scrollable region is
// keyboard-accessible; Tab still dismisses through listKeyDown. With
// a header or footer the menu is one Tab stop between them.
tabIndex={hasOverflow || hasRegions ? 0 : -1}

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.

With a header or footer this makes the role="menu" element a keyboard Tab stop, but styles.dropdown still sets outline: 'none' on the premise that keyboard focus always moves to a row. In Chromium, Tab from the header field or Shift+Tab from the footer leaves focus here with no visible indicator and no focused row (WCAG 2.2 SC 2.4.7). Moving focus to a row when the menu receives keyboard focus, or painting a keyboard-modality indicator here, would fix it.

Comment on lines +1059 to +1062
const region = e.shiftKey ? headerRef.current : footerRef.current;
if (tabbablesIn(region).length > 0) {
return;
}

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.

Returning without preventDefault lets the browser's sequential navigation start from the focused row, and that row's previous tabbable in tree order is its own tabIndex={0} menu ancestor. So after a keyboard open, Shift+Tab from a row lands on the menu element first and only a second Shift+Tab reaches the header. Focusing the header's last tabbable (or the footer's first, for Tab) explicitly here would make the menu the single stop the PR describes.

Comment on lines +72 to +75
await expect(page.getByRole('menuitem')).toHaveText([
'Documentation',
'Design',
]);

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 story filters by substring and only “Design” contains de, so this assertion fails at this head (it receives ['Design']). Expecting ['Design'], or typing a query both labels contain such as d, would make it pass.

…ab from a row reaches the header

Between a header and a footer the menu element is a Tab stop, but its base
style removes the ring for the pointer-open focus target, so keyboard focus
there was invisible (WCAG 2.2 SC 2.4.7). It now draws the shared focus-visible
ring when regions are present.

Shift+Tab from a focused row stopped on the menu element itself, the row's
ancestor and a Tab stop, before reaching the header. It now moves straight
to the header's last control, so the menu stays one stop.

Corrects the Chromium spec's filter expectation (only Design contains "de")
and adds cases for Shift+Tab from a row and for the visible ring.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec b5bd412

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

Thanks — the earlier findings are addressed and the proposed header/footer rows have the owner's approval, but two focus issues in the new path need fixing before this can be approved:

  • Shift+Tab from a focused row lands on the footer's “Create label” button instead of the header, because the popover's focus trap handles the same Tab again after listKeyDown focuses the header, so the new Chromium test “Shift+Tab from a row goes straight to the header” fails (the pull-request CI job does not run that spec).
  • Opening the menu with a mouse now paints the keyboard focus ring around the rows, because focusOutlineStyles.focusVisible keys on :focus-visible alone, while architecture:interaction-modality INV1 keeps the ring hidden after pointer input.

[Automated review]

Comment on lines +1065 to +1067
if (e.shiftKey && e.target !== listRef.current) {
e.preventDefault();
tabbables[tabbables.length - 1].focus();

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 this moves focus to the header, the event keeps bubbling to the popover's focus trap (useFocusTrap's document keydown listener), which sees Shift+Tab with focus on the popover's first focusable and wraps it to the last. In Chromium, Shift+Tab from a row therefore lands on the footer's “Create label”, and MenuHeaderFooter.a11y.chromium.spec.ts “Shift+Tab from a row goes straight to the header” fails. Keeping the trap from handling this Tab again once focus has moved (stopping the event here, or having the trap skip a Tab whose default is already prevented) would fix it.

// Between a header and a footer the menu is a Tab stop, so
// keyboard focus on it must be visible (the base style removes
// the ring for the pointer-open focus target).
hasRegions && focusOutlineStyles.focusVisible,

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.

focusVisible keys on :focus-visible alone, and Chromium matches it when a mouse open focuses the menu programmatically, so a click-open of a menu with a header or footer paints the keyboard ring around the rows (architecture:interaction-modality INV1 keeps the indicator hidden after pointer input). Gating this on the shared modality, the way the trigger uses isFocusRingSuppressed && focusOutlineStyles.suppressed, would keep the ring for keyboard focus only.

…ing after a pointer open

Shift+Tab from a row focused the header, then the popover's document-level
focus trap read the same key against that field (the trap's first element)
and wrapped to the footer. The handled key now stops propagating.

The menu's ring keyed on :focus-visible alone, so a mouse open, which
focuses the menu programmatically, painted the keyboard ring. Following
architecture:interaction-modality INV1, the ring now draws only when the menu
itself took focus from the keyboard.

Adds unit and Chromium cases for both.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 4b1aa0f

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

Thanks — both focus issues from the last round are fixed: Shift+Tab from a row now reaches the header in one step, a mouse open no longer paints the keyboard ring, and the rest of the popover behavior checks out in Chromium. One keyboard gap remains before this can be approved: in a menu with header or footer and a sub-menu, Tab or Shift+Tab from a row of the open sub-menu leaves its flyout open and moves focus to the footer or to the menu element itself, so the menu is no longer a single Tab stop. Please make those keys close the sub-menu and continue as they do from its row in the root menu, and add a sub-menu case to the header-and-footer tests.

[Automated review]

// From a row, the browser's Shift+Tab would stop on the menu element
// itself — the row's ancestor and a Tab stop — before reaching the
// header. The menu is one stop, so go straight to the header.
if (e.shiftKey && e.target !== listRef.current) {

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 hand-off only runs for Tab events this level owns: a Tab from a row of an open sub-menu has already returned at the ownsEvent check above, so with a header or footer present the browser's own Tab moves focus out of the flyout — Shift+Tab to this menu element (an extra stop), Tab to the footer — and the flyout stays open. In Chromium, a menu with header, footer and a flyout DropdownMenuSubMenu shows exactly that, while the same menu without regions keeps focus in the flyout. Closing the sub-menu and continuing as from its row here would keep the menu a single Tab stop.

…region

With a header or footer, Tab or Shift+Tab from a row of an open sub-menu
left the flyout open and let the browser move focus to the footer or to the
menu element, so the menu was no longer one Tab stop. Each open flyout now
closes itself as Tab bubbles past it, and the root menu moves focus to the
footer (Tab) or header (Shift+Tab), or closes when there is nothing to
reach, as from one of its own rows.

The flyouts learn that the root has regions through a small internal
context, not exported from the package. A plain context rather than a
layer-scoped one, because each flyout is its own layer and must still see
the root's value. FR15 states the sub-menu case. Unit and Chromium cases are
added, and the story gains a sub-menu.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 8b317a3

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

Thanks — the sub-menu gap from the last round is fixed: in Chromium, Tab and Shift+Tab from an open sub-menu now close it and land on the footer or header, and the rest of the header and footer behavior checks out. One fix is still needed before approval: MenuHeaderFooter.a11y.chromium.spec.ts, the verification FR15 relies on, now fails all nine tests because the story's new "Move to" sub-menu row also matches #storybook-root [aria-haspopup="menu"]. Please scope that locator to the trigger button and let the structure test allow the sub-menu's nested menu role, which sits inside the root menu element.

[Automated review]

});

const STORY = 'core-dropdownmenu--header-and-footer';
const TRIGGER = '#storybook-root [aria-haspopup="menu"]';

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 story's new "Move to" DropdownMenuSubMenu row also carries aria-haspopup="menu" and is mounted while the menu is closed, so this selector resolves to two elements and every test fails at page.locator(TRIGGER).click() with a Playwright strict-mode violation (9 of 9 in Chromium at this revision). Scoping it to the button — '#storybook-root button[aria-haspopup="menu"]' or page.getByRole('button', {name: 'Labels'}) — makes the other eight tests pass, including the new sub-menu case.

const roles = await menu.evaluate(el =>
Array.from(el.querySelectorAll('[role]')).map(n => n.getAttribute('role')),
);
expect(new Set(roles)).toEqual(new Set(['menuitem']));

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.

With the trigger locator fixed, this still fails: the sub-menu's flyout renders its own role="menu" inside the root menu element, so the set is {menu, menuitem}. Admitting the nested flyout's menu here, while the textbox and button checks below keep proving the regions sit outside, would make it pass.

… every pull request

The story's new sub-menu row also carries aria-haspopup="menu", so the spec's
trigger locator matched two elements and all nine cases failed. The locator
now takes the trigger button only, the root menu is found by name, and the
structure case allows the sub-menu row's own nested menu inside the root.

The spec is also added to pr-a11y with its own --output directory, as the
other component contracts are, so FR15's real-engine verification runs on
pull requests instead of only in the release check.

Run locally in Chrome 155 against the CI Storybook build of 8b317a3 (the
story is unchanged since): 9 passed.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 02bc287

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

One fix is needed before approval; everything else checks out, and the Chromium spec now passes 9 of 9, including in pr-a11y. tabbablesIn counts controls that are present but hidden (hidden, display: none, visibility: hidden) as reachable, so with such content in header or footer, Shift+Tab from a row does nothing, Tab past the footer wraps to the header instead of closing the menu, and Tab from an open sub-menu can leave focus on the page body. Please decide reachability with the popover focus trap's own test (getFocusableElements / isVisiblyFocusable in useFocusTrap.ts) and add a test with a hidden control in each region.

[Automated review]

}
return Array.from(
region.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR),
).filter(element => element.tabIndex >= 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.

This keeps controls Tab cannot reach — hidden, display: none, visibility: hidden — so the hand-offs treat a region holding one as reachable. In Chromium, with a hidden button after the header field, Shift+Tab from a row does nothing; with one after “Create label”, Tab past it wraps to the header instead of closing; and with the footer's only control hidden, Tab from an open sub-menu leaves focus on the page body with the menu open. The popover's focus trap already filters with isVisiblyFocusable (hooks/useFocusTrap.ts); reusing that test here (for example by exporting getFocusableElements) and adding a case with a hidden control in each region would keep FR15's “a control Tab can reach” true.

…b target

The region reachability check counted controls that are present but hidden
(hidden, display: none, visibility: hidden) as reachable. With such content,
Shift+Tab from a row did nothing, Tab past the footer wrapped to the header
instead of closing, and Tab from an open sub-menu could leave focus on the
page body.

Reachability now uses the popover focus trap's own test: getFocusableElements
from useFocusTrap, exported from that module for this use and not re-exported
from the package's hooks entry. The two can no longer disagree about where
Tab can go. Adds cases with a hidden control in each region; five of the six
fail against the previous check.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec fa3baf5

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

Thanks — the hidden-control cases from the last round are fixed: a control that is itself hidden, display: none or visibility: hidden is now skipped, and the rest of the header and footer behavior checks out in Chromium. One gap remains before approval: isVisiblyFocusable reads only the control's own computed display, so a control inside a display: none wrapper (for example one hidden at some widths) still counts as reachable — Shift+Tab from a row then does nothing, and Tab past “Create label”, or from an open sub-menu when that control is the footer's only one, leaves focus on the page body with the menu still open. Please treat a display: none ancestor inside the region as unreachable in tabbablesIn (falling back to closing the menu when focus does not move) and add a wrapped-control case for each region.

[Automated review]

if (region == null) {
return [];
}
return getFocusableElements(region).filter(element => element.tabIndex >= 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.

getFocusableElements filters with isVisiblyFocusable, which checks hidden, inert and aria-hidden ancestors but reads display only from the control's own computed style — and display is not inherited. So a control inside a display: none wrapper still counts as reachable here. In Chromium on the HeaderAndFooter story, with <div style="display:none"><button>…</button></div> added after the field, Shift+Tab from a row does nothing; added after “Create label”, Tab past it leaves focus on the page body with the menu open; as the footer's only control, Tab from an open sub-menu does the same. Dropping controls with a display: none ancestor inside the region (or checkVisibility() where available, with an ancestor walk for jsdom), plus a fallback to closeMenu() when .focus() does not land, would keep FR15's “a control Tab can reach” true; a wrapped-control test per region would pin it.

… a Tab target

The focus trap's visibility test reads only the control's own display, so a
control inside a display: none wrapper (one hidden at some widths, say) still
counted as reachable. Shift+Tab from a row then did nothing, and Tab past the
last visible footer control, or from an open sub-menu, left focus on the page
body with the menu open.

tabbablesIn now also rejects a control under a display: none ancestor within
its region. Moving focus to a region control reports whether focus arrived,
and the menu closes when it did not, so focus is never stranded.

Adds a wrapped-control case for each region and path; all four fail without
the check. Two earlier sub-menu cases passed only because the flyout's own
close also calls hidePopover; they now assert the root popover closed.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec cab3ffb

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

Thanks — the display: none wrapper case from the last round is fixed: a control hidden by a wrapper in header or footer is now skipped, and Tab past either region, including from an open sub-menu, closes the menu and moves on just as it does in a menu without regions. The header and footer suites and the Chromium contract pass at this revision, and nothing else blocks approval.

[Automated review]

@cixzhang
cixzhang merged commit 61639ee into main Oct 11, 2026
45 checks passed
@github-actions
github-actions Bot deleted the dropdown-menu-header-footer branch October 12, 2026 06:35
cixzhang added a commit that referenced this pull request Oct 15, 2026
…g, and Tab wraps (#7515)

## User impact

A `DropdownMenu` with a `header` or `footer` exposed `aria-haspopup="menu"` on its trigger, and its popover then held a filter field or a "Create" button that isn't a menu item. Keyboard users who Tabbed past either end found the popover closed out from under them.

Now the popover is exposed as a named modal dialog with the menu inside it. The trigger exposes `aria-haspopup="dialog"`, and Tab cycles through the header, the menu and the footer until Escape or a press outside closes it. A menu without either prop is unchanged.

## What changes

- **Dialog, only with regions:** the popover is `role="dialog"` with `aria-modal="true"`, named like the menu. It holds the header, the `role="menu"` element (rows only) and the footer.
- **Trigger, only with regions:** `aria-haspopup="dialog"`, and `aria-controls` names the popover that holds the dialog, the same convention Popover's own trigger uses. A custom trigger's name is read once it mounts, so the dialog is never unnamed.
- **Tab wraps:** Tab and Shift+Tab move through the header's controls, the menu as one stop, then the footer's controls, and wrap at either end. Hidden controls and controls under a hidden wrapper are skipped. From an open sub-menu the flyout closes and focus continues from the menu's stop. With no other stop, focus stays in the menu.
- **Unchanged:** Escape closes and returns focus to the trigger; focus on open (FR6, FR12); the bottom sheet, which is already a dialog; and every menu without `header` or `footer`, which keeps `aria-haspopup="menu"` and closes on Tab.

## Current specification

`component:DropdownMenu` (draft):

- **DEC-10** (new): with a header or footer, the popover is a modal dialog with the menu inside, and Tab wraps. Decided by @cixzhang on 2026-10-13.
- **AR5** (new): the APG Dialog (Modal) pattern's required parts, under `spec:AST-020/FR15`.
- **AR4:** its carve-out now names a pointer menu with regions next to the bottom sheet.
- **FR15:** the concept row, FR15 itself and its verification row state the dialog and the wrap.
- **DEC-8:** its Tab sentence points to DEC-10.

This fixes behavior shipped in 0.7.0 (#7344).


## Compatibility

Classified `[fix]` under `spec:AST-017/FR53` and DEC-20 (#7523), owner decision by @cixzhang on 2026-10-14: accessibility behavior fixes are not breaking.

- **No app-layer code change:** `DropdownMenuTriggerProps` already typed `aria-haspopup` as `'menu' | 'dialog'`; no prop, callback signature, ref target or export changes; `onOpenChange` still reports every close; documented composition (`header`, `footer`, rows as children) is unchanged.
- **Documented behavior that changes (release-note line):** with a header or footer, Tab past either end now wraps inside the dialog instead of closing the menu, so `onOpenChange(false)` no longer fires on that Tab; the trigger exposes `aria-haspopup="dialog"` and `aria-controls` names the popover.
- An app's own tests asserting the old Tab-close or `aria-haspopup="menu"` on a header/footer menu would see the new behavior; no runtime code needs to change.

## Writing rubric results

- R1 narration: none. FR15, AR5 and DEC-10 describe the system in the present tense.
- R2 research in the record: none.
- R3 evidence naming a change: none. The FR15 verification row names the unit suite and the Chromium spec.
- R4 rejected alternatives over one line or outside a decision: one, in one sentence inside DEC-10 (closing on Tab past either end).
- R5 pull request or issue references remaining: none in the record.
- R6 ruled open questions still listing options: none.

## Evidence

- **Scope of the accessibility claim:** it ends at what the browser exposes (role, name, `aria-modal`, `aria-haspopup`), proved by accessibility-tree assertions in Chromium (AST-009 FR3). No NVDA or VoiceOver run was made, so nothing here claims what a screen reader announces.

- `DropdownMenu.test.tsx`, header and footer suite, 26 cases: two new ones for the dialog role and trigger wiring with and without regions, and the end-of-Tab and hidden-control cases rewritten from close to wrap.
- `MenuHeaderFooter.a11y.chromium.spec.ts`: the Tab walk now asserts the wrap at both ends, and a new case checks the dialog role, `aria-modal`, its name, the menu and regions inside it, and that the trigger's `aria-controls` holds the dialog. It runs in `pr-a11y`.
- DropdownMenu, ContextMenu, Breadcrumbs, Popover, BottomSheet, focus-trap and doc-prop suites: 689 passed. Types and lint clean; `check:knowledge` and `check:changesets` pass.

## Scope

- [x] One fix: dialog semantics for a popover with regions.
- [x] Consumer docs, story text, focused tests and a changeset ship with it.
- [x] Public text and artifacts contain no internal Meta context.
cixzhang pushed a commit that referenced this pull request Oct 21, 2026
…#7530)

> Data items' `header` and `footer`, and the bottom sheet's level regions, follow once this merges.

## User need

A sub-menu picking from a long list needs a filter field above its rows, often a "Create" button below. #7344 gave the root menu `header` and `footer`; a sub-menu has neither, so the field goes among the rows (DEC-8 forbids it) or the picker leaves the menu.

## Problem and solution fit

`DropdownMenuSubMenu` takes `header` and `footer` under the root's rules (DEC-8, DEC-10). With either, the sub-menu's surface (the flyout, or the drilled-in view on a phone) is a modal dialog named by its row, holding the header, the sub-menu's `role="menu"` with rows only, and the footer. A flyout renders inside its parent menu, so `DropdownMenu` renders a host beside its menu for the dialog. A drilled-in view with regions replaces the root's menu and regions until popped, by a style rule that reads the host.

```tsx
<DropdownMenuSubMenu label="Labels" header={<TextInput label="Filter labels" … />} footer={<Button label="Create label" … />}>
  {visibleLabelRows}
</DropdownMenuSubMenu>
```

## Current specification

`component:DropdownMenu` (draft) gains a concept row, FR20, AR7 and DEC-13, all proposed and pending owner review. Other proposals in open pull requests: #7319 FR18/DEC-11, #7352 FR19/DEC-12, #7532 FR21/DEC-14, #7541 FR22/DEC-15. `module:DropdownMenu/useMenuPress` (current) gains a proposed ORD1a: a press released on a row of that dialog's menu acts, as FR1 requires for any flyout; a picker placed in its header or footer stays its own press root.

## Public delta and caller burden

- `header` and `footer` on `DropdownMenuSubMenu`.
- With either, the row says `aria-haspopup="dialog"`; Tab walks header, rows as one stop, footer, and wraps; an Escape nothing inside handled returns to the row; a pointer leaving the flyout keeps it open until focus leaves. Rendered beside the root's menu, such a flyout closes with the flyout holding its row.
- Phone drill-in: a shown view follows its regions and caps at the root's `menuMaxHeight`.
- `ContextMenu` renders no host: there the sub-menu shows its rows alone and warns in development; parity follows once this merges.
- Without them, nothing changes.

## Design and alternatives

Rejected: regions inside the flyout (inside the parent menu); a separate `DropdownMenu` per level; closing on pointer-leave, losing typed text. A drilled-in view's header sits above Back.

## Writing rubric results

- R1 narration: none.
- R2 research in a record: none.
- R3 evidence naming a change: none.
- R4 rejected alternatives over one line or outside a decision: none.
- R5 pull request or issue references: none.
- R6 ruled open questions listing options: none.

## Evidence

See Testing.

## Scope

- [x] One capability is added.
- [x] Unrelated fixes, cleanup, and policy changes were removed or split.
- [x] Consumer docs, focused tests, a story and a changeset ship with the feature.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

Review round 8 (rebased onto `main` b74cf21): `pr-a11y` gets a "Run DropdownMenu sub-menu header and footer contract" step beside "Run DropdownMenu header and footer contract". It runs `SubMenuHeaderFooter.a11y.chromium.spec.ts` with `--project chromium`, so FR20's real-engine checks gate every head. That exact command passes locally against a Storybook built from this head (6 cases). 15 files, +1867/−121 (1,988 lines). DropdownMenu, ContextMenu, Layer, MoreMenu, RadioList, `useMenuPress` and doc-prop suites: 739 tests; header and footer Chromium specs: 16; `.github/scripts` workflow tests: 100; typecheck, `lint:strict`, `check:knowledge`, Storybook build: clean.

Review round 7 (rebased onto `main` 863e167): `surfaceHost`, `surfaceOwnerId` and `menuMaxHeight` leave the exported `DropdownMenuContextValue` for `DropdownMenuSurfaceContext`, which the package does not export, layer-scoped and re-provided by each flyout as the menu context is; the public type matches `main`. A new `DropdownMenuContext.public.test.ts` pins its four members (it fails typecheck with the three back) and checks the internal context is not exported. Data-mode parity (data items' `header` and `footer`, `renderDropdownItems`, the bottom sheet's warning and their tests) moves to the follow-up, and the three pointer-leave cases share one setup: 14 files, +1856/−121 (1,977 lines). DropdownMenu, ContextMenu, Layer, MoreMenu, RadioList, `useMenuPress` and doc-prop suites: 739 tests; header and footer Chromium specs: 16; typecheck, `lint:strict` (no warnings), `check:knowledge`, Storybook build: clean.

Rebased onto `main` d0f9afe, no conflicts or changes. The previous head's `pr-a11y` and `smoke-test` reds came from CI: main's #7802 added a `pr-a11y` step whose spec file the older head lacked, and jsdelivr was still propagating [email protected]. DropdownMenu, ContextMenu, RadioList, docProp* suites: 477 tests; typecheck, `check:knowledge`: clean.

Review round 6: a flyout the pointer has left now decides that focus left once the move has completed, so an arrow key in a header radio group, where the browser moves focus itself, no longer closes it. A jsdom case replays the browser's order (focusout, a microtask checkpoint, focusin) and fails on the previous head; a Chromium case on the new "Submenu / header with a choice" story presses ArrowDown after the pointer leaves, and fails against a Storybook built from the previous head, where the flyout closes. DropdownMenu, ContextMenu, Layer, MoreMenu, RadioList, `useMenuPress` and doc-prop suites: 741 tests; header and footer Chromium specs: 16; typecheck, `lint:strict`, `check:knowledge`, Storybook build: clean.

Review round 5 (rebased onto `main` 2c3ed99; the earlier `test` and `test-node` reds were `main`'s own, a PostCSS fixture that #7797 fixed): an Escape a control in a region already handled (a header menu closing, a field clearing itself) closes nothing more, and the new case fails on the previous head. The contract takes FR20, AR7 and DEC-13 so open proposals in this record stay distinct. DropdownMenu, ContextMenu, Layer, MoreMenu, `useMenuPress` and doc-prop suites: 646 tests; header and footer Chromium specs: 15; typecheck, `lint:strict`, `check:knowledge`, Storybook build: clean.

Rebased onto `main` 577a62e after #7737 merged: one commit, 15 files, +1733/−109. DropdownMenu, ContextMenu, Layer, MoreMenu, `useMenuPress` and doc-prop suites: 645 tests; header and footer Chromium specs: 15; typecheck, `lint:strict`, `check:knowledge`, Storybook build: clean.

Review round 4 (amended into the last commit): the surface host is owned through a ref, with only a key in state that changes when a host attaches (it moves when the root's header or footer comes or goes); a drilled-in view with regions caps at the root's `menuMaxHeight`. New cases: the view cap (fails on the previous head) and the host move (a guard). Gates below are for this head.

Round 3, then stacked on #7737: the root steps aside for a view by a style rule over its surface host instead of a drill-in record kept in an Effect; a flyout with regions closes from the `onHide` of the flyout holding its row instead of an Effect; the bottom sheet's level regions moved to a follow-up. Each change has a case that fails with it reverted.

- `DropdownMenuSubMenu.test.tsx` "header and footer" suite: 20 cases, plus one in `ContextMenu.test.tsx` (rows alone, with the warning). They cover the dialog's role, modality, name and row wiring; regions outside every menu; the Tab walk and wrap from a field, a row and a deeper flyout; field keys; Escape, an IME Escape and Escapes a region handled; a press from a menu row released on a dialog row (acts) or its field (outside); a menu placed in a region keeping its own press; pointer-leave with focus inside, focus moving within (a header radio's arrow included), then focus leaving; a nested flyout closing with its parent; the phone drill-in, the root stepping aside, a shown view following its regions and its height cap.
- `__tests__/SubMenuHeaderFooter.a11y.chromium.spec.ts`, real Chromium: six cases (laptop structure, keyboard walk, picks, press-drag pick, a header radio after the pointer leaves; phone drill-in with the root stepped aside).
- iOS 26.2 simulator (Mobile Safari), earlier head: phone drill-in as described above; on `main` the level has no field or button.

This branch was successfully deployed

1 active deployment
Preview — cab3ffbd Deployed Oct 11, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant