@astryxdesign/core 0.7.3-canary.b74cf21 → 0.7.3-canary.cb489ff

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  2. package/dist/CheckboxInput/CheckboxInput.js +19 -24
  3. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  4. package/dist/DropdownMenu/DropdownMenu.js +52 -10
  5. package/dist/DropdownMenu/DropdownMenuContext.d.ts +34 -1
  6. package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
  7. package/dist/DropdownMenu/DropdownMenuContext.js +15 -0
  8. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts +21 -2
  9. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  10. package/dist/DropdownMenu/DropdownMenuSubMenu.js +375 -42
  11. package/dist/DropdownMenu/menuRegionStops.d.ts +2 -2
  12. package/dist/DropdownMenu/menuRegionStops.js +2 -2
  13. package/dist/FileInput/FileInput.d.ts.map +1 -1
  14. package/dist/FileInput/FileInput.js +14 -12
  15. package/dist/Slider/Slider.d.ts.map +1 -1
  16. package/dist/Slider/Slider.js +7 -14
  17. package/dist/Switch/Switch.d.ts.map +1 -1
  18. package/dist/Switch/Switch.js +12 -14
  19. package/dist/Switch/switch.markers.stylex.d.ts +2 -0
  20. package/dist/Switch/switch.markers.stylex.d.ts.map +1 -1
  21. package/dist/Switch/switch.markers.stylex.js +6 -0
  22. package/dist/TimeInput/TimeInput.d.ts +2 -1
  23. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  24. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  25. package/dist/Tooltip/Tooltip.js +36 -14
  26. package/dist/TopNav/TopNav.d.ts.map +1 -1
  27. package/dist/TopNav/TopNav.js +2 -2
  28. package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
  29. package/dist/TopNav/TopNavHeading.js +1 -0
  30. package/dist/astryx.css +3 -2
  31. package/dist/hooks/useMenuPress.d.ts +11 -1
  32. package/dist/hooks/useMenuPress.d.ts.map +1 -1
  33. package/dist/hooks/useMenuPress.js +43 -5
  34. package/dist/utils/timeParser.d.ts +4 -0
  35. package/dist/utils/timeParser.d.ts.map +1 -1
  36. package/dist/utils/timeParser.js +9 -2
  37. package/package.json +3 -3
  38. package/src/CheckboxInput/CheckboxInput.test.tsx +44 -5
  39. package/src/CheckboxInput/CheckboxInput.tsx +16 -26
  40. package/src/CheckboxInput/__tests__/Checkbox.a11y.states.ts +3 -3
  41. package/src/CheckboxList/CheckboxList.test.tsx +9 -6
  42. package/src/ContextMenu/ContextMenu.test.tsx +41 -0
  43. package/src/DropdownMenu/DropdownMenu.spec.md +33 -2
  44. package/src/DropdownMenu/DropdownMenu.tsx +79 -8
  45. package/src/DropdownMenu/DropdownMenuContext.public.test.ts +22 -0
  46. package/src/DropdownMenu/DropdownMenuContext.tsx +39 -1
  47. package/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs +16 -1
  48. package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +623 -1
  49. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +556 -99
  50. package/src/DropdownMenu/__tests__/SubMenuHeaderFooter.a11y.chromium.spec.ts +267 -0
  51. package/src/DropdownMenu/menuRegionStops.ts +2 -2
  52. package/src/DropdownMenu/modules/useMenuPress.spec.md +9 -0
  53. package/src/FileInput/FileInput.test.tsx +30 -7
  54. package/src/FileInput/FileInput.tsx +21 -11
  55. package/src/SideNav/SideNav.test.tsx +35 -0
  56. package/src/Slider/Slider.test.tsx +3 -3
  57. package/src/Slider/Slider.tsx +8 -15
  58. package/src/Switch/Switch.test.tsx +29 -8
  59. package/src/Switch/Switch.tsx +13 -14
  60. package/src/Switch/__tests__/Switch.a11y.states.ts +2 -2
  61. package/src/Switch/switch.markers.stylex.ts +4 -0
  62. package/src/Table/plugins/selection/useTableSelection.test.tsx +5 -3
  63. package/src/TimeInput/TimeInput.doc.mjs +5 -3
  64. package/src/TimeInput/TimeInput.test.tsx +20 -0
  65. package/src/TimeInput/TimeInput.tsx +2 -1
  66. package/src/Tooltip/Tooltip.test.tsx +51 -6
  67. package/src/Tooltip/Tooltip.tsx +41 -18
  68. package/src/Tooltip/__tests__/Tooltip.a11y.chromium.spec.ts +129 -0
  69. package/src/Tooltip/__tests__/Tooltip.a11y.renders.tsx +86 -0
  70. package/src/Tooltip/__tests__/Tooltip.a11y.states.ts +132 -0
  71. package/src/Tooltip/__tests__/Tooltip.a11y.test.tsx +126 -0
  72. package/src/TopNav/TopNav.tsx +11 -1
  73. package/src/TopNav/TopNavHeading.tsx +1 -0
  74. package/src/TopNav/__tests__/TopNavMobileLongHeading.a11y.chromium.spec.ts +74 -0
  75. package/src/hooks/useMenuPress.ts +45 -7
  76. package/src/utils/timeParser.test.ts +11 -0
  77. package/src/utils/timeParser.ts +9 -2
@@ -19,7 +19,6 @@
19
19
  import {
20
20
  useId,
21
21
  useCallback,
22
- use,
23
22
  useOptimistic,
24
23
  useRef,
25
24
  useTransition,
@@ -52,7 +51,6 @@ import {usePressFeedback} from '../hooks/usePressFeedback';
52
51
  import {useResolvedRequired} from '../hooks/useResolvedRequired';
53
52
  import {useIndicator} from '../Indicator';
54
53
  import {themeProps} from '../utils/themeProps';
55
- import {CheckboxListContext} from '../CheckboxList/CheckboxListContext';
56
54
 
57
55
  import {useMergedRefs} from '../hooks/useMergedRefs';
58
56
 
@@ -354,21 +352,10 @@ export function CheckboxInput({
354
352
  const [optimisticValue, setOptimisticValue] = useOptimistic(value);
355
353
  const isBusy = isLoading || optimisticValue !== value;
356
354
 
357
- // Disabled-reason tooltip. Disabled controls swallow pointer events, so the
358
- // tooltip listeners attach to the checkbox row (which already exists) and the
359
- // native checkbox stays perceivable via aria-disabled instead of the disabled
360
- // attribute. Value mutation is blocked by the isDisabled guard in onChange.
355
+ // A disabled checkbox stays focusable via aria-disabled instead of the
356
+ // native disabled attribute (spec:AST-085 FR1). Value mutation is blocked by
357
+ // the click and onChange guards on the input.
361
358
  const showsDisabledMessage = isDisabled && !!disabledMessage;
362
- // Keep the native checkbox focusable via aria-disabled either when it renders
363
- // its own reason tooltip, or when it sits in a CheckboxList whose whole-group
364
- // `disabledMessage` (shown on the group container) needs each checkbox to
365
- // stay keyboard-perceivable. The group signals this through context rather
366
- // than a public prop.
367
- const checkboxListContext = use(CheckboxListContext);
368
- const isFocusableDisabled =
369
- isDisabled &&
370
- (showsDisabledMessage ||
371
- (checkboxListContext?.hasDisabledMessage ?? false));
372
359
  const disabledMessageTooltip = useTooltip({
373
360
  placement: 'above',
374
361
  // The container row is not naturally focusable; focusin bubbles up from the
@@ -384,7 +371,7 @@ export function CheckboxInput({
384
371
  // `opacity: 0`, and only the indicator's own element can shape the outline
385
372
  // to match it. See useIndicatorFocusRing.
386
373
  const indicatorRef = useRef<HTMLSpanElement>(null);
387
- const {focusProps} = useIndicatorFocusRing(indicatorRef, isDisabled);
374
+ const {focusProps} = useIndicatorFocusRing(indicatorRef);
388
375
 
389
376
  const isIndeterminate = optimisticValue === 'indeterminate';
390
377
  const isChecked = optimisticValue === true;
@@ -471,22 +458,25 @@ export function CheckboxInput({
471
458
  )}
472
459
  id={id}
473
460
  type="checkbox"
474
- // Withhold the name while disabled: with a disabledMessage the
475
- // input stays focusable (not natively disabled), and a disabled
476
- // control must not submit.
461
+ // Withhold the name while disabled: the input stays focusable (not
462
+ // natively disabled), and a disabled control must not submit.
477
463
  name={isDisabled ? undefined : htmlName}
478
464
  checked={isChecked}
479
- // With a disabledMessage the checkbox keeps focusability via
480
- // aria-disabled so the reason is focus-discoverable; toggling is
481
- // still blocked by the isDisabled guard in onChange below.
482
- disabled={isDisabled && !isFocusableDisabled}
483
- aria-disabled={isFocusableDisabled ? 'true' : undefined}
484
- form={isFocusableDisabled ? '' : undefined}
465
+ aria-disabled={isDisabled ? 'true' : undefined}
466
+ // Detached from its form while disabled, so it neither submits nor
467
+ // blocks submission through `required` (spec:AST-085 FR3).
468
+ form={isDisabled ? '' : undefined}
469
+ // Native `disabled` suppressed onClick (FR2); preventDefault here
470
+ // would desync React's controlled checked state.
471
+ onClick={isDisabled ? undefined : rest.onClick}
485
472
  readOnly={isReadOnly}
486
473
  required={isRequired}
487
474
  aria-required={isEffectivelyRequired ? 'true' : undefined}
488
475
  onChange={e => {
489
476
  if (isDisabled || isBusy || isReadOnly) {
477
+ // Activation clears the native mixed state; React restores
478
+ // only `checked`, so restore `indeterminate` too.
479
+ e.target.indeterminate = isIndeterminate;
490
480
  return;
491
481
  }
492
482
  const checked = e.target.checked;
@@ -125,8 +125,8 @@ export const CHECKBOX_BINDING_STATES = [
125
125
  {
126
126
  id: 'input-disabled',
127
127
  binding: 'CheckboxInput',
128
- summary: 'a natively disabled checkbox outside the tab sequence',
129
- facts: facts({operable: false, focusable: false, disabled: true}),
128
+ summary: 'a disabled checkbox that keeps its tab stop',
129
+ facts: facts({operable: false, focusable: true, disabled: true}),
130
130
  visibleLabel: 'Managed setting',
131
131
  storyId: 'a11y-checkbox-pattern--input-disabled',
132
132
  },
@@ -269,7 +269,7 @@ export const CHECKBOX_BINDING_STATES = [
269
269
  id: 'list-item-disabled',
270
270
  binding: 'CheckboxListItem',
271
271
  summary: 'an individually disabled list item',
272
- facts: facts({operable: false, focusable: false, disabled: true}),
272
+ facts: facts({operable: false, focusable: true, disabled: true}),
273
273
  visibleLabel: 'SMS',
274
274
  visibleLabelSelector: '[data-a11y-visible-label]',
275
275
  storyId: 'a11y-checkbox-pattern--list-item-disabled',
@@ -288,8 +288,9 @@ describe('CheckboxList', () => {
288
288
  </CheckboxList>,
289
289
  );
290
290
  const checkboxes = screen.getAllByRole('checkbox');
291
- expect(checkboxes[0]).toBeDisabled();
292
- expect(checkboxes[1]).toBeDisabled();
291
+ expect(checkboxes[0]).toHaveAttribute('aria-disabled', 'true');
292
+ expect(checkboxes[1]).toHaveAttribute('aria-disabled', 'true');
293
+ expect(checkboxes[0]).not.toHaveAttribute('disabled');
293
294
  });
294
295
 
295
296
  it('does not call onChange when group is disabled', () => {
@@ -317,8 +318,9 @@ describe('CheckboxList', () => {
317
318
  </CheckboxList>,
318
319
  );
319
320
  const checkboxes = screen.getAllByRole('checkbox');
320
- expect(checkboxes[0]).not.toBeDisabled();
321
- expect(checkboxes[1]).toBeDisabled();
321
+ expect(checkboxes[0]).not.toHaveAttribute('aria-disabled');
322
+ expect(checkboxes[1]).toHaveAttribute('aria-disabled', 'true');
323
+ expect(checkboxes[1]).not.toHaveAttribute('disabled');
322
324
  });
323
325
 
324
326
  it('throws when item has no value prop inside collection-mode CheckboxList', () => {
@@ -1137,7 +1139,7 @@ describe('CheckboxListItem ARIA props', () => {
1137
1139
  expect(onChange).not.toHaveBeenCalled();
1138
1140
  });
1139
1141
 
1140
- it('keeps checkboxes natively disabled when disabled without a reason', () => {
1142
+ it('keeps checkboxes focusable via aria-disabled when disabled without a reason', () => {
1141
1143
  render(
1142
1144
  <CheckboxList
1143
1145
  label="Notifications"
@@ -1149,7 +1151,8 @@ describe('CheckboxListItem ARIA props', () => {
1149
1151
  </CheckboxList>,
1150
1152
  );
1151
1153
  for (const checkbox of screen.getAllByRole('checkbox', h)) {
1152
- expect(checkbox).toBeDisabled();
1154
+ expect(checkbox).not.toHaveAttribute('disabled');
1155
+ expect(checkbox).toHaveAttribute('aria-disabled', 'true');
1153
1156
  }
1154
1157
  });
1155
1158
  });
@@ -24,6 +24,7 @@ import {
24
24
  ContextMenuRadioItem,
25
25
  } from './index';
26
26
  import {DropdownMenuItem} from '../DropdownMenu/DropdownMenuItem';
27
+ import {DropdownMenuSubMenu} from '../DropdownMenu/DropdownMenuSubMenu';
27
28
  import {Divider} from '../Divider';
28
29
  import {useLayerDismissal} from '../Layer/useLayerDismissal';
29
30
  import {warmMenuBottomSheet} from '../DropdownMenu/__tests__/warmMenuBottomSheet';
@@ -706,6 +707,46 @@ describe('ContextMenu dividers', () => {
706
707
  });
707
708
 
708
709
  describe('ContextMenu compound mode', () => {
710
+ it('shows a sub-menu with a header or footer as its rows alone, and says why in development', async () => {
711
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
712
+ try {
713
+ render(
714
+ <ContextMenu
715
+ menuContent={
716
+ <>
717
+ <DropdownMenuItem label="Rename" onClick={() => {}} />
718
+ <DropdownMenuSubMenu
719
+ label="Labels"
720
+ header={<input aria-label="Filter labels" />}
721
+ footer={<button type="button">Create label</button>}>
722
+ <DropdownMenuItem label="Bug" onClick={() => {}} />
723
+ </DropdownMenuSubMenu>
724
+ </>
725
+ }>
726
+ <div>Right-click me</div>
727
+ </ContextMenu>,
728
+ );
729
+ fireEvent.contextMenu(screen.getByText('Right-click me'));
730
+ const row = screen.getByRole('menuitem', {name: /Labels/, hidden: true});
731
+ // No region can sit outside this menu, so none renders inside it.
732
+ expect(row).toHaveAttribute('aria-haspopup', 'menu');
733
+ fireEvent.click(row, {detail: 1});
734
+ await waitFor(() => expect(row).toHaveAttribute('aria-expanded', 'true'));
735
+ expect(screen.queryByRole('dialog', {hidden: true})).toBeNull();
736
+ expect(
737
+ screen.queryByRole('textbox', {name: 'Filter labels', hidden: true}),
738
+ ).toBeNull();
739
+ expect(
740
+ screen.getByRole('menuitem', {name: 'Bug', hidden: true}),
741
+ ).toBeInTheDocument();
742
+ expect(warn).toHaveBeenCalledWith(
743
+ expect.stringContaining('DropdownMenuSubMenu: header and footer'),
744
+ );
745
+ } finally {
746
+ warn.mockRestore();
747
+ }
748
+ });
749
+
709
750
  it('renders menuContent as menu items', () => {
710
751
  render(
711
752
  <ContextMenu
@@ -86,7 +86,7 @@ Consumer migration instructions belong in consumer docs and release notes.
86
86
  ## Public concepts
87
87
 
88
88
  Consumer props, item shapes, subcomponents, and presentation policy remain
89
- documented in `DropdownMenu.doc.mjs` and the subcomponent docs. Three component-local concepts are added, by DEC-2, DEC-3 and DEC-8; each
89
+ documented in `DropdownMenu.doc.mjs` and the subcomponent docs. Four component-local concepts are added, by DEC-2, DEC-3, DEC-8 and proposed DEC-13; each
90
90
  keeps its released default.
91
91
 
92
92
  | Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
@@ -94,6 +94,7 @@ keeps its released default.
94
94
  | Menu height cap | `menuMaxHeight`: a number of pixels | Lifts the 300px cap for a menu that must fit its rows; the viewport still bounds it. | Pointer presentation | `300px` | `component:DropdownMenu` | stable | Ignored by the touch sheet. |
95
95
  | Trigger source | `button` (Button props) or `renderTrigger` (render prop) | Which control the menu hangs off. `trigger` receives `DropdownMenuTriggerProps` — the press model, keyboard opens, toggle click and ARIA wiring — and names the menu. | Both presentations | `button` | `component:DropdownMenu` | stable | Both given: `trigger` wins and a dev warning fires. |
96
96
  | Header and footer | `header`, `footer`: any React node | Content above and below the rows, beside the menu inside the same popover or sheet — never inside the `role="menu"` element. With either, the pointer popover is a modal dialog around the menu. | Both presentations | none | `component:DropdownMenu` | stable | A false or empty value renders no region. |
97
+ | Sub-menu regions | `header`, `footer` on a sub-menu: any React node | Content above and below a sub-menu's rows, beside its menu inside its own surface; with either, that surface is a modal dialog named by the row (proposed FR20). | Popover presentation | none | `component:DropdownMenu` | proposed | A false or empty value renders no region. |
97
98
 
98
99
  ## Behavioral and layout contract
99
100
 
@@ -119,6 +120,7 @@ keeps its released default.
119
120
  | FR15 | With `header` or `footer`, the pointer popover is a `role="dialog"` with `aria-modal="true"`, named like the menu, holding the header, then the `role="menu"` element, then the footer; the menu element holds only its rows. The trigger says `aria-haspopup="dialog"` and its `aria-controls` names the popover that holds the dialog. A region keeps its own keys and presses: neither the menu's key handling nor its press model claims an event that begins there. The menu is one Tab stop between the regions. Tab and Shift+Tab move through the header's controls, the menu, then the footer's controls, and wrap at either end; a control that is hidden, or under a hidden ancestor within its region, is not a stop. From a row, or a row of an open sub-menu, Tab and Shift+Tab close every open flyout and continue from the menu's stop. With no other stop, focus stays in the menu. Escape closes from anywhere in the popover, and focus returns to the trigger. The bottom sheet, already a dialog, shows the header above the actions and the footer below them. Without either prop, the menu renders and behaves exactly as it does without them: no dialog, `aria-haspopup="menu"`, and Tab closes the menu. | DEC-8, DEC-10, docs, and tests | Proposed; awaiting owner approval |
120
121
  | FR16 | `DropdownMenuCheckboxItem` MUST expose one `menuitemcheckbox` row whose `aria-checked` equals its controlled value; enabled activation reports `!value`, stays open by default, and composes consumer click and pointer-move handlers with owned activation and hover focus. Disabled activation calls no consumer activation handler. | Released subcomponent API; `architecture:public-component-api/INV5–INV8`; `DropdownMenuSelectable.test.tsx` | Verified current behavior; consumer handlers are preserved |
121
122
  | FR17 | Disabled menu rows SHOULD remain keyboard-discoverable while activation stays blocked. Current shared `useListFocus` deliberately skips every `aria-disabled` row, including checkbox items. | WAI-ARIA Menu pattern; current shared navigation source/tests | Objective mismatch; shared mechanism remains undecided in OQ1 |
123
+ | FR20 | With `header` or `footer` on a sub-menu (`DropdownMenuSubMenu`), its surface is a modal dialog named by its row (AR7), holding the header, the sub-menu's `role="menu"` (rows only), then the footer. It sits in a host `DropdownMenu` renders beside its menu, never inside a menu; under a root with no such host (`ContextMenu`) the sub-menu shows its rows alone. On a fine pointer the dialog is the flyout; on a compact touch display, the drilled-in view, which replaces the root's menu and regions until popped. A region keeps its own keys and presses. The rows are one Tab stop: Tab and Shift+Tab walk the header's controls, the rows, then the footer's, and wrap; from a deeper flyout, that flyout closes and the walk goes on from the rows. An open lands as for any sub-menu (FR11, FR12), not on a region. Escape in the dialog, outside an IME composition and unless a control there handled it, returns focus to the row and leaves the root open. A pointer leaving the flyout keeps it open until focus leaves, and it closes with the flyout holding its row. Without either prop nothing changes. | Proposed DEC-13; FR15; AR5 | Proposed; verified in jsdom and Chromium, pending owner review |
122
124
 
123
125
  ### Allowed variation
124
126
 
@@ -200,13 +202,20 @@ visibility helper.
200
202
  trigger keeps `aria-expanded`; its `aria-haspopup` says `dialog`, and its
201
203
  `aria-controls` names the popover that holds the dialog rather than the
202
204
  menu, as Popover's own trigger does.
203
-
204
205
  - **AR6 — Checkbox rows remain one control.** The row owns
205
206
  `menuitemcheckbox`, its accessible name, checked state, focus, and activation;
206
207
  Indicator's checkbox marker is decorative. Disabled activation is inert.
207
208
  Current shared navigation skips disabled rows instead of making them
208
209
  discoverable as the WAI-ARIA Menu pattern recommends; FR17 and OQ1 retain that
209
210
  gap without inventing a component-local focus path.
211
+ - **AR7 (proposed) — A sub-menu with a header or footer adopts the same APG
212
+ Dialog (Modal) parts for its own surface** (`spec:AST-020/FR15`):
213
+ `role="dialog"`, `aria-modal="true"`, and an accessible name, its row's;
214
+ focus moves into the dialog on open, to the sub-menu's first row or its
215
+ menu as FR11 and FR12 already state; Tab and Shift+Tab cycle within it
216
+ (FR20); Escape closes it and focus returns to the row. The sub-menu's menu
217
+ inside keeps AR3. The row keeps `aria-expanded`; its `aria-haspopup` says
218
+ `dialog` and its `aria-controls` names the dialog.
210
219
 
211
220
  ## Design relationships
212
221
 
@@ -324,6 +333,7 @@ than adding a DropdownMenu-owned heading target.
324
333
  | FR15 | `DropdownMenu.test.tsx` header and footer suite; `__tests__/MenuHeaderFooter.a11y.chromium.spec.ts` in real Chromium | dialog role, modality, name and trigger wiring; regions outside the menu element; typing in a header field; Tab walk header → menu → footer with wrap at both ends; Tab and Shift+Tab from an open sub-menu; hidden and hidden-wrapper controls; Escape from the header; a finger tap on a footer button; bottom sheet order; no regions | A region rendered inside the menu element, a popover with regions that is not a named modal dialog, a trigger still saying `aria-haspopup="menu"` with regions, a header key taken by typeahead, a Tab that leaves the dialog or closes it, focus stranded outside the dialog, or a footer tap swallowed by the press model fails. |
325
334
  | FR16 | `DropdownMenuSelectable.test.tsx`, source inspection, scoped `pr-a11y` over the `a11y/Checkbox pattern` stories, and owned Storybook states | checked, unchecked, disabled, caller click/pointer handlers, marker size and ownership | A dropped consumer handler, wrong checked state, nested semantic checkbox, disabled activation, or menu that closes by default fails. | `audit:DropdownMenuCheckboxItem/behavior` |
326
335
  | FR17, AR6 | Shared navigation source and DropdownMenu keyboard tests | disabled checkbox row first, middle, and last | Current tests prove the shared hook skips the row; no keyboard-discoverability proof exists until OQ1 is settled. | `audit:DropdownMenuCheckboxItem/accessibility` |
336
+ | FR20, AR7 | `DropdownMenuSubMenu.test.tsx` "header and footer" suite; `ContextMenu.test.tsx` rows-alone case; `__tests__/SubMenuHeaderFooter.a11y.chromium.spec.ts` in real Chromium (fine pointer, coarse pointer) | flyout and phone view; dialog role, name, row wiring; regions outside menus; Tab walk and wrap from a field, row, deeper flyout; field keys, presses; Escape, IME and handled Escapes; keyboard open; pointer leaving, focus in then out; parent closing a nested flyout; view tracking its regions; ContextMenu rows alone | A region inside a menu element, a surface with regions that is not a named modal dialog, a row still saying `aria-haspopup="menu"`, a field key taken by the menu, a Tab that leaves or closes the dialog, a flyout closed under focus by a pointer leaving, a flyout outliving its parent, or the root menu beside a view, fails. | `audit:DropdownMenu/behavior` |
327
337
 
328
338
  ## Decision log
329
339
 
@@ -541,3 +551,24 @@ the menu. Tab and Shift+Tab wrap within the dialog, as the APG Dialog
541
551
  pattern requires; Escape and a press outside close it. Without either prop
542
552
  the component is unchanged: a Menu Button whose Tab closes the menu. Rejected:
543
553
  closing on Tab past either end, which leaves a modal dialog by Tab.
554
+
555
+ ### DEC-13 (proposed) — A sub-menu's header and footer make its surface a dialog beside the menu
556
+
557
+ **Reference:** `component:DropdownMenu/DEC-13`
558
+ **Decider:** proposed by `vjeux`, 2026-10-14; pending owner review
559
+
560
+ A filter field above a sub-menu's rows, or a door below them, is a control
561
+ that is not a menu item, so DEC-8 and DEC-10 apply to the sub-menu's own
562
+ surface as they apply to the root's: the sub-menu's menu holds only its rows,
563
+ and the surface around it is a named modal dialog whose Tab order wraps. A
564
+ flyout renders inside the menu that holds its row, so a dialog there would
565
+ still sit inside that menu; the `DropdownMenu` therefore renders a host beside its menu,
566
+ inside its popover, and a sub-menu with regions renders its surface there (the
567
+ flyout layer, or the drilled-in view, which then takes the root menu's place).
568
+ Rendered there, a flyout no longer hides with the flyout that holds its row,
569
+ so it closes with it. The pointer leaving that flyout does not close it while
570
+ focus is inside, because what was typed into its field would go with it.
571
+ Rejected: regions inside the flyout beside the sub-menu's menu,
572
+ which puts them inside the parent menu; a separate DropdownMenu for the level,
573
+ which loses the row, the drill-in and the single press model; and closing the
574
+ flyout when the pointer leaves it as any flyout does.
@@ -61,7 +61,10 @@ import {
61
61
  import {
62
62
  DropdownMenuContext,
63
63
  DropdownMenuRootOpenContext,
64
+ DropdownMenuSurfaceContext,
64
65
  type DropdownMenuContextValue,
66
+ type DropdownMenuSurfaceHost,
67
+ type DropdownMenuSurfaceValue,
65
68
  } from './DropdownMenuContext';
66
69
  import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';
67
70
  import {useListFocus} from '../hooks/useListFocus';
@@ -112,6 +115,14 @@ const MENU_MAX_BLOCK_SIZE = `min(${MENU_BLOCK_CAP}, ${layerViewportInset.maxBloc
112
115
  const MENU_MAX_BLOCK_SIZE_FALLBACK = `min(${MENU_BLOCK_CAP}, ${layerViewportInset.maxBlockSizeFallback})`;
113
116
  const MENU_TRIGGER_OPEN_BACKGROUND = `linear-gradient(${colorVars['--color-overlay-pressed']}, ${colorVars['--color-overlay-pressed']})`;
114
117
 
118
+ // A sub-menu's drilled-in view with a header or footer renders in the surface
119
+ // host that follows the menu, as the frame marked
120
+ // `data-astryx-submenu-regions="view"` (hidden while a deeper view shows).
121
+ // While one shows, the menu and its header and footer step aside. The rule
122
+ // reads that from the DOM, so no state mirrors which view shows.
123
+ const STEPS_ASIDE_FOR_VIEW =
124
+ ':has(~ * > [data-astryx-submenu-regions="view"]:not([hidden]))';
125
+
115
126
  const styles = stylex.create({
116
127
  triggerOpen: {
117
128
  backgroundImage: MENU_TRIGGER_OPEN_BACKGROUND,
@@ -125,7 +136,12 @@ const styles = stylex.create({
125
136
  },
126
137
  dropdown: {
127
138
  boxSizing: 'border-box',
128
- display: 'flex',
139
+ display: {
140
+ default: 'flex',
141
+ // A sub-menu's drilled-in view with a header or footer shows in its
142
+ // place (see `stepsAsideForView`).
143
+ [STEPS_ASIDE_FOR_VIEW]: 'none',
144
+ },
129
145
  flexDirection: 'column',
130
146
  gap: spacingVars['--spacing-0-5'],
131
147
  // Pointer opens focus this container so subsequent arrow keys and Escape
@@ -175,6 +191,22 @@ const styles = stylex.create({
175
191
  flexShrink: 1,
176
192
  minBlockSize: 0,
177
193
  },
194
+ // Where a sub-menu with a header or footer renders its surface: beside the
195
+ // menu, never inside it. It owns no box, so the popover's layout is
196
+ // unchanged.
197
+ surfaceHost: {
198
+ display: 'contents',
199
+ },
200
+ // While a sub-menu's drilled-in view with its own header or footer shows
201
+ // in the surface host, the header and footer step aside for it, as the menu
202
+ // does (see `dropdown`). Derived from the DOM by the rule itself: the view
203
+ // is the frame in the host that is not hidden.
204
+ stepsAsideForView: {
205
+ display: {
206
+ default: null,
207
+ [STEPS_ASIDE_FOR_VIEW]: 'none',
208
+ },
209
+ },
178
210
  region: {
179
211
  flexShrink: 0,
180
212
  padding: spacingVars['--spacing-1'],
@@ -1455,12 +1487,39 @@ function DropdownMenuPopover({
1455
1487
 
1456
1488
  // The drill-in view stack for sub-menus on a phone.
1457
1489
  const {drillIn, wrapContent} = useMenuDrillIn(isOpen);
1490
+ // The surface host is owned through a ref. State keeps only a key that
1491
+ // changes whenever a host element attaches, the host included when it
1492
+ // moves (a header or footer coming or going), so sub-menus re-render into
1493
+ // the element that is mounted.
1494
+ const surfaceHostRef = useRef<HTMLDivElement | null>(null);
1495
+ const [surfaceHostKey, setSurfaceHostKey] = useState(0);
1496
+ const attachSurfaceHost = useCallback((node: HTMLDivElement | null) => {
1497
+ surfaceHostRef.current = node;
1498
+ if (node != null) {
1499
+ setSurfaceHostKey(key => key + 1);
1500
+ }
1501
+ }, []);
1502
+ const surfaceHost = useMemo<DropdownMenuSurfaceHost>(
1503
+ () => ({
1504
+ getElement: () => (surfaceHostKey > 0 ? surfaceHostRef.current : null),
1505
+ }),
1506
+ [surfaceHostKey],
1507
+ );
1458
1508
  const resolvedMaxHeight = menuMaxHeight == null ? null : `${menuMaxHeight}px`;
1459
1509
  // Context for compound items
1460
1510
  const contextValue = useMemo<DropdownMenuContextValue>(
1461
1511
  () => ({closeMenu, menuSize, drillIn, menuLabel}),
1462
1512
  [closeMenu, menuSize, drillIn, menuLabel],
1463
1513
  );
1514
+ // What a sub-menu with a header or footer needs, on an internal context.
1515
+ const surfaceValue = useMemo<DropdownMenuSurfaceValue>(
1516
+ () => ({
1517
+ host: surfaceHost,
1518
+ ownerId: menuId,
1519
+ menuMaxHeight: resolvedMaxHeight ?? undefined,
1520
+ }),
1521
+ [surfaceHost, menuId, resolvedMaxHeight],
1522
+ );
1464
1523
 
1465
1524
  // Resolve menu content: data-driven items become components
1466
1525
  const menuContent = wrapContent(
@@ -1469,7 +1528,13 @@ function DropdownMenuPopover({
1469
1528
  const hasOverflow = useMenuOverflow(listRef, menuContent, popover.isOpen);
1470
1529
 
1471
1530
  // The header and footer sit beside the menu inside the popover, never inside
1472
- // the role="menu" element: a menu holds only its rows.
1531
+ // the role="menu" element: a menu holds only its rows. The surface host
1532
+ // follows the menu, so a sub-menu with a header or footer renders beside the
1533
+ // menu too; while such a sub-menu's drilled-in view shows there, the menu and
1534
+ // the regions step aside (STEPS_ASIDE_FOR_VIEW).
1535
+ const surfaceHostElement = (
1536
+ <div ref={attachSurfaceHost} {...stylex.props(styles.surfaceHost)} />
1537
+ );
1473
1538
  const renderWithRegions = (menu: ReactNode): ReactNode =>
1474
1539
  hasRegions ? (
1475
1540
  <div
@@ -1482,7 +1547,7 @@ function DropdownMenuPopover({
1482
1547
  <div
1483
1548
  ref={headerRef}
1484
1549
  onKeyDown={handleRegionKeyDown}
1485
- {...stylex.props(styles.region)}>
1550
+ {...stylex.props(styles.region, styles.stepsAsideForView)}>
1486
1551
  {header}
1487
1552
  </div>
1488
1553
  )}
@@ -1491,13 +1556,17 @@ function DropdownMenuPopover({
1491
1556
  <div
1492
1557
  ref={footerRef}
1493
1558
  onKeyDown={handleRegionKeyDown}
1494
- {...stylex.props(styles.region)}>
1559
+ {...stylex.props(styles.region, styles.stepsAsideForView)}>
1495
1560
  {footer}
1496
1561
  </div>
1497
1562
  )}
1563
+ {surfaceHostElement}
1498
1564
  </div>
1499
1565
  ) : (
1500
- menu
1566
+ <>
1567
+ {menu}
1568
+ {surfaceHostElement}
1569
+ </>
1501
1570
  );
1502
1571
 
1503
1572
  const triggerProps: DropdownMenuTriggerProps = {
@@ -1636,9 +1705,11 @@ function DropdownMenuPopover({
1636
1705
  )}>
1637
1706
  <MenuRegionsContext value={hasRegions}>
1638
1707
  <DropdownMenuContext value={contextValue}>
1639
- <DropdownMenuRootOpenContext value={isOpen}>
1640
- {menuContent}
1641
- </DropdownMenuRootOpenContext>
1708
+ <DropdownMenuSurfaceContext value={surfaceValue}>
1709
+ <DropdownMenuRootOpenContext value={isOpen}>
1710
+ {menuContent}
1711
+ </DropdownMenuRootOpenContext>
1712
+ </DropdownMenuSurfaceContext>
1642
1713
  </DropdownMenuContext>
1643
1714
  </MenuRegionsContext>
1644
1715
  </div>,
@@ -0,0 +1,22 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file DropdownMenuContext.public.test.ts
5
+ * @input The DropdownMenu barrel and its public `DropdownMenuContextValue`
6
+ * @output Guards that the menu context keeps its members and that the internal
7
+ * surface context a sub-menu with a header or footer reads is not exported
8
+ * @position Public API test guarding @astryxdesign/core/DropdownMenu
9
+ */
10
+
11
+ import {describe, expect, expectTypeOf, it} from 'vitest';
12
+ import * as dropdownMenu from './index';
13
+ import type {DropdownMenuContextValue} from './index';
14
+
15
+ describe('DropdownMenu public context', () => {
16
+ it('keeps its members and exports no surface context', () => {
17
+ expectTypeOf<keyof DropdownMenuContextValue>().toEqualTypeOf<
18
+ 'closeMenu' | 'menuSize' | 'drillIn' | 'menuLabel'
19
+ >();
20
+ expect('DropdownMenuSurfaceContext' in dropdownMenu).toBe(false);
21
+ });
22
+ });
@@ -45,7 +45,10 @@ export interface DropdownMenuDrillIn {
45
45
  viewStack: ReadonlyArray<string>;
46
46
  /** The element a shown view renders its rows into (a portal target). */
47
47
  host: HTMLElement | null;
48
- /** Show a sub-menu's view in place of the current rows. */
48
+ /**
49
+ * Show a sub-menu's view in place of the current rows. A view with a header
50
+ * or footer renders into the root's surface host instead of `host`.
51
+ */
49
52
  push: (viewId: string) => void;
50
53
  /** Return to the rows the shown view replaced. */
51
54
  pop: () => void;
@@ -65,6 +68,41 @@ export interface DropdownMenuContextValue {
65
68
  menuLabel?: string;
66
69
  }
67
70
 
71
+ /**
72
+ * The root's surface host. The root owns the element through a ref; this
73
+ * object is new whenever a new element attaches, so a sub-menu re-renders
74
+ * into it.
75
+ */
76
+ export interface DropdownMenuSurfaceHost {
77
+ /** The host element, or `null` before it attaches. */
78
+ getElement: () => HTMLElement | null;
79
+ }
80
+
81
+ /** What a sub-menu with a header or footer needs from the root. Internal. */
82
+ export interface DropdownMenuSurfaceValue {
83
+ /**
84
+ * An element inside the root's popover but outside every `role="menu"`
85
+ * element, where such a sub-menu renders its surface (its flyout layer, or
86
+ * its drilled-in view, while which the root's menu and regions step aside).
87
+ */
88
+ host: DropdownMenuSurfaceHost;
89
+ /**
90
+ * The root menu's `id`, which a sub-menu's menu in the host names so the
91
+ * press model counts it, and only it, as nested in the root.
92
+ */
93
+ ownerId: string;
94
+ /** The root's resolved `menuMaxHeight`, which a drilled-in view caps at. */
95
+ menuMaxHeight?: string;
96
+ }
97
+
98
+ /**
99
+ * The root's surface; `null` under a root with none (ContextMenu). Internal,
100
+ * off the public menu context, and layer-scoped, so each flyout re-provides it.
101
+ */
102
+ export const DropdownMenuSurfaceContext =
103
+ createLayerScopedContext<DropdownMenuSurfaceValue | null>(null);
104
+ DropdownMenuSurfaceContext.displayName = 'DropdownMenuSurfaceContext';
105
+
68
106
  /**
69
107
  * Whether the root menu of this layer tree is open; internal companion to
70
108
  * `DropdownMenuContext`, on its own unexported context so the public
@@ -67,6 +67,18 @@ export const docs = {
67
67
  "How the sub-menu shows its rows. 'flyout' opens them beside the row; 'drill-in' replaces the menu's rows with them and a Back row, in the same box; 'adaptive' drills in when a finger opened the menu (a coarse pointer, decided when the menu opened) and flies out otherwise.",
68
68
  default: "'adaptive'",
69
69
  },
70
+ {
71
+ name: 'header',
72
+ type: 'ReactNode',
73
+ description:
74
+ 'Content above the sub-menu\'s rows and outside its menu, a field that filters them, say. It keeps its own keys and presses. With a header or footer the sub-menu\'s surface (the flyout, or the drilled-in view on a phone) is a modal dialog named by the row, beside the menu rather than inside it: the row says aria-haspopup="dialog", Tab and Shift+Tab move through the header, the rows and the footer and wrap, Escape returns to the row, and a pointer leaving the flyout closes it only once focus leaves too. A ContextMenu does not show it.',
75
+ },
76
+ {
77
+ name: 'footer',
78
+ type: 'ReactNode',
79
+ description:
80
+ "Content below the sub-menu's rows and outside its menu, a door to where the options are managed, say. Same rules as header.",
81
+ },
70
82
  {
71
83
  name: 'xstyle',
72
84
  type: 'StyleXStyles',
@@ -77,7 +89,7 @@ export const docs = {
77
89
  name: 'ref',
78
90
  type: 'React.Ref<HTMLElement>',
79
91
  description:
80
- 'Ref forwarded to the trigger row, the element carrying role="menuitem" and aria-haspopup="menu".',
92
+ 'Ref forwarded to the trigger row, the element carrying role="menuitem" and aria-haspopup="menu" ("dialog" with a header or footer).',
81
93
  },
82
94
  ],
83
95
  };
@@ -100,6 +112,9 @@ export const docsDense = {
100
112
  onOpenChange: 'called when flyout opens/closes',
101
113
  presentation:
102
114
  "'flyout' beside the row | 'drill-in' replaces the rows + Back row | 'adaptive' (default) drills in on a coarse pointer",
115
+ header:
116
+ 'content above the rows, outside the menu; surface becomes a modal dialog named by the row (Tab wraps, Escape returns to the row)',
117
+ footer: 'content below the rows, outside the menu; same rules as header',
103
118
  xstyle: 'StyleX styles for the trigger row',
104
119
  ref: 'ref to the trigger row (role="menuitem")',
105
120
  },