Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(DropdownMenuSubMenu): delay and hideDelay set the hover timing (#10298)

Cindy Zhang68e8d6d436e7
diff --git a/.changeset/submenu-hover-delay.md b/.changeset/submenu-hover-delay.md
new file mode 100644
index 0000000000..98f95a75c3
--- /dev/null
+++ b/.changeset/submenu-hover-delay.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[feat] `DropdownMenuSubMenu` accepts `delay` and `hideDelay`, in milliseconds, the same options `Tooltip`, `HoverCard` and `TopNavMenu` have. `delay` is how long a hovering pointer waits before the flyout opens (default 150), and `hideDelay` is how long the flyout stays after the pointer leaves (default 200). The defaults match today's timing, so nothing changes unless you pass them. Keyboard focus and touch never wait.
+
+@cixzhang
diff --git a/docs/specs/components/DropdownMenu/DropdownMenuSubMenu.spec.md b/docs/specs/components/DropdownMenu/DropdownMenuSubMenu.spec.md
index 0a8bf0a361..2b7ddfb36c 100644
--- a/docs/specs/components/DropdownMenu/DropdownMenuSubMenu.spec.md
+++ b/docs/specs/components/DropdownMenu/DropdownMenuSubMenu.spec.md
@@ -42,11 +42,11 @@ system_specs: [spec:AST-020, spec:AST-086]
| Area | Contract |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Public contract | One `menuitem` row with a required label and children, optional icon, description, loading caret, disabled state, flyout width, presentation, header, footer, open callback, test ids, root inputs, and a ref. |
+| Public contract | One `menuitem` row: label, children; optional icon, description, loading caret, disabled state, flyout width, presentation, `delay`, `hideDelay`, header, footer, open callback, test ids, root inputs, a ref. |
| Behavior | The row reveals its children as a flyout beside it or as a drilled-in view led by a Back row; with a header or footer that surface is a modal dialog named by the row. |
| End-user impact | Pointer, keyboard, and touch users reach nested commands from one row; assistive technology hears the row's popup kind and expanded state, and Escape or the close arrow returns to the row. |
| Builder impact | Place the row inside a DropdownMenu or ContextMenu and give it a label and rows; data-driven menus get it from a nested `items` array. |
-| Compatibility/readiness | Records shipped behavior; no API change; a disabled row gains `tabindex="-1"` (FR7). |
+| Compatibility/readiness | Records shipped behavior; adds optional `delay` and `hideDelay` (FR11) at the released timing; a disabled row gains `tabindex="-1"` (FR7). |
| Review checks | Reject a second keyboard owner, a lost popup state, a flyout that does not flip under RTL, a disabled row that opens, dropped caller inputs, or an open callback that misses a transition. |
| Governing rules | `spec:AST-020` FR15; `architecture:public-component-api/INV5–INV8`; `architecture:react-component-runtime/INV2`; `architecture:layer-runtime`; `spec:AST-020/FR1,FR2`; `spec:AST-086/FR8`. |
@@ -65,9 +65,10 @@ host that a sub-menu with a header or footer renders into.
## Compatibility and migration
- Released default preserved: yes (`isDisabled=false`, `hasSpinner=false`,
- `presentation='adaptive'`).
-- Compatibility class: records shipped behavior; no public prop or export
- change; a disabled row gains `tabindex="-1"` (FR7).
+ `presentation='adaptive'`, `delay=150`, `hideDelay=200`).
+- Compatibility class: additive; the row adds optional `delay` and `hideDelay`
+ (FR11), whose defaults are the released timing; a disabled row gains
+ `tabindex="-1"` (FR7).
- Controlled behavior: the open state is internal; `onOpenChange` reports it.
- Migration decision: none.
@@ -120,6 +121,7 @@ Consumer migration instructions belong in consumer docs and release notes.
| FR8 | With `hasSpinner` the row shows a decorative spinner in place of the caret and announces the busy start once the root menu shows. | `spec:AST-086` FR8; current source and tests |
| FR9 | Ref, supported host attributes and handlers, `className`, `style`, and `xstyle` reach or compose on the row root after the row's own behavior; the open keys and a disabled click stop before the caller's handler. | `architecture:public-component-api` INV5–INV8; current tests |
| FR10 | Without its own `header` or `footer` and with none on a level above it, Tab or Shift+Tab on a row in the flyout closes this level as the key bubbles to the menu, which closes the whole menu (`component:DropdownMenu` FR23, `component:ContextMenu` FR11). | WAI-ARIA Menu Button pattern; current tests |
+| FR11 | On a hover-capable pointer, the flyout opens after `delay` and closes `hideDelay` after the pointer has left the row, the flyout and the path toward it (`component:DropdownMenu` FR13), in milliseconds (defaults 150 and 200). Keyboard focus and touch never wait. | Owner decision, 2026-11-06 |
### Allowed variation
@@ -203,6 +205,7 @@ No component-local visual decision is recorded.
| FR5 | `DropdownMenuSubMenu.test.tsx` "closes the whole menu after selecting a nested item" and "activates a nested item with the Enter key and closes the menu" | Pointer and Enter | A level left open after a leaf pick fails. | `audit:DropdownMenuSubMenu/behavior` |
| FR6 | `DropdownMenuSubMenu.test.tsx` "reports each flyout open and close to onOpenChange once" | Flyout open and close | A missing or repeated report fails. Evidence gap: the drill-in reset gap is not asserted. | `audit:DropdownMenuSubMenu/behavior` |
| FR10 | `DropdownMenuSubMenu.test.tsx` "Tab from a flyout leaves the whole menu" suite; `ContextMenu.test.tsx` matching case | one and two levels down, Shift+Tab | A flyout left open after Tab fails. | `audit:DropdownMenuSubMenu/accessibility` |
+| FR11 | `DropdownMenuSubMenu.test.tsx` "opens 150 ms after a hover and closes 200 ms after the pointer leaves by default", "waits the `delay` it is given before a hover opens the flyout" and "keeps the flyout open for the `hideDelay` it is given after the pointer leaves" | `delay`; `hideDelay`; defaults | A flyout that opens before `delay` or closes before `hideDelay` fails. | `audit:DropdownMenuSubMenu/behavior` |
| FR7, FR9 | `DropdownMenuSubMenu.test.tsx` "does not open a disabled submenu", "a disabled row does not pass a click on to the caller's onClick", host-attribute and ref cases ("aria-\*, data-\* and id reach the trigger row, and the flyout stays labelled by it", "a ref reaches the trigger row", "a caller's handlers run after the row's own, and the row still opens and takes the hover focus") | Disabled; caller handlers and attributes | A disabled open or caller click, or a dropped attribute, ref, or handler, fails. Evidence gap: no test asserts `className`, `style`, or `xstyle` on the row, a disabled row's `tabindex="-1"`, or that the parent's keyboard reaches it (`component:DropdownMenu` FR17). | `audit:DropdownMenuSubMenu/api` |
| FR8 | `BusyOwnerAnnouncement.test.tsx` "DropdownMenuSubMenu loading state" cases; `DropdownMenuSubMenu.test.tsx` loading-flyout cases | Loading closed and open | A busy start announced while closed, twice, or not at all, or an announced Spinner, fails. | `audit:DropdownMenuSubMenu/accessibility` |
| AR4, PR1 | `DropdownMenuForcedColors.test.tsx` (the row's `:focus-visible` ring and token inset); `DropdownMenuAudit.a11y.chromium.spec.ts` forced-colors frames. Evidence gap: no test asserts the timer bounds | — | — | `audit:DropdownMenuSubMenu/visual` |
diff --git a/packages/core/api-report.md b/packages/core/api-report.md
index afc8e6b520..a491733ceb 100644
--- a/packages/core/api-report.md
+++ b/packages/core/api-report.md
@@ -234,10 +234,12 @@ component BreadcrumbMenuRadioItem(props: DropdownMenuRadioItemProps)
component BreadcrumbMenuSubMenu(props: DropdownMenuSubMenuProps)
prop children: ReactNode
prop data-testid?: string
+ prop delay?: number = 150
prop description?: ReactNode
prop footer?: ReactNode
prop hasSpinner?: boolean = false
prop header?: ReactNode
+ prop hideDelay?: number = 200
prop icon?: ReactNode | IconType
prop isDisabled?: boolean = false
prop label: ReactNode
@@ -851,10 +853,12 @@ component ContextMenuRadioItem(props: DropdownMenuRadioItemProps)
component ContextMenuSubMenu(props: DropdownMenuSubMenuProps)
prop children: ReactNode
prop data-testid?: string
+ prop delay?: number = 150
prop description?: ReactNode
prop footer?: ReactNode
prop hasSpinner?: boolean = false
prop header?: ReactNode
+ prop hideDelay?: number = 200
prop icon?: ReactNode | IconType
prop isDisabled?: boolean = false
prop label: ReactNode
@@ -1114,10 +1118,12 @@ component DropdownMenuRadioItem(props: DropdownMenuRadioItemProps)
component DropdownMenuSubMenu(props: DropdownMenuSubMenuProps)
prop children: ReactNode
prop data-testid?: string
+ prop delay?: number = 150
prop description?: ReactNode
prop footer?: ReactNode
prop hasSpinner?: boolean = false
prop header?: ReactNode
+ prop hideDelay?: number = 200
prop icon?: ReactNode | IconType
prop isDisabled?: boolean = false
prop label: ReactNode
@@ -3729,10 +3735,12 @@ interface BreadcrumbMenuSection
interface BreadcrumbMenuSubMenuProps extends DropdownMenuSubMenuBaseProps
children: ReactNode
data-testid?: string
+ delay?: number = 150
description?: ReactNode
footer?: ReactNode
hasSpinner?: boolean = false
header?: ReactNode
+ hideDelay?: number = 200
icon?: ReactNode | IconType
isDisabled?: boolean = false
label: ReactNode
@@ -4073,10 +4081,12 @@ type ContextMenuSection = DropdownMenuSection
interface ContextMenuSubMenuProps extends DropdownMenuSubMenuBaseProps
children: ReactNode
data-testid?: string
+ delay?: number = 150
description?: ReactNode
footer?: ReactNode
hasSpinner?: boolean = false
header?: ReactNode
+ hideDelay?: number = 200
icon?: ReactNode | IconType
isDisabled?: boolean = false
label: ReactNode
diff --git a/packages/core/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs b/packages/core/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs
index b74358faba..476345b823 100644
--- a/packages/core/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs
+++ b/packages/core/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs
@@ -69,6 +69,20 @@ export const docs = {
"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.",
default: "'adaptive'",
},
+ {
+ name: 'delay',
+ type: 'number',
+ description:
+ 'How long a hovering pointer waits before the flyout opens, in milliseconds. Keyboard focus and touch never wait.',
+ default: '150',
+ },
+ {
+ name: 'hideDelay',
+ type: 'number',
+ description:
+ 'How long the flyout stays open after the pointer leaves, in milliseconds.',
+ default: '200',
+ },
{
name: 'header',
type: 'ReactNode',
@@ -120,6 +134,8 @@ export const docsDense = {
onOpenChange: 'called when flyout opens/closes',
presentation:
"'flyout' beside the row | 'drill-in' replaces the rows + Back row | 'adaptive' (default) drills in on a coarse pointer",
+ delay: 'hover wait before the flyout opens, ms (default 150)',
+ hideDelay: 'how long the flyout stays after the pointer leaves, ms (default 200)',
header:
'content above the rows, outside the menu; surface becomes a modal dialog named by the row (Tab wraps, Escape returns to the row)',
footer: 'content below the rows, outside the menu; same rules as header',
diff --git a/packages/core/src/DropdownMenu/DropdownMenuSubMenu.test.tsx b/packages/core/src/DropdownMenu/DropdownMenuSubMenu.test.tsx
index 9a23665bb8..2f30412fdc 100644
--- a/packages/core/src/DropdownMenu/DropdownMenuSubMenu.test.tsx
+++ b/packages/core/src/DropdownMenu/DropdownMenuSubMenu.test.tsx
@@ -1076,6 +1076,114 @@ describe('DropdownMenuSubMenu theming slots', () => {
});
});
+function TimedMoveMenu({
+ delay,
+ hideDelay,
+}: {
+ delay?: number;
+ hideDelay?: number;
+}) {
+ return (
+ <DropdownMenu button={{label: 'Actions'}}>
+ <DropdownMenuItem label="Rename" onClick={() => {}} />
+ <DropdownMenuSubMenu label="Move to" delay={delay} hideDelay={hideDelay}>
+ <DropdownMenuItem label="Folder A" onClick={() => {}} />
+ </DropdownMenuSubMenu>
+ </DropdownMenu>
+ );
+}
+
+describe('DropdownMenuSubMenu hover timing', () => {
+ it('opens 150 ms after a hover and closes 200 ms after the pointer leaves by default', async () => {
+ vi.useFakeTimers({shouldAdvanceTime: true});
+ const user = userEvent.setup({advanceTimers: vi.advanceTimersByTime});
+ render(<TimedMoveMenu />);
+
+ await user.click(screen.getByRole('button', {name: /Actions/}));
+ const trigger = screen.getByRole('menuitem', {
+ name: /Move to/,
+ hidden: true,
+ });
+ await user.hover(trigger);
+ act(() => {
+ vi.advanceTimersByTime(100);
+ });
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
+ act(() => {
+ vi.advanceTimersByTime(100);
+ });
+ expect(trigger).toHaveAttribute('aria-expanded', 'true');
+
+ await user.hover(
+ screen.getByRole('menuitem', {name: 'Rename', hidden: true}),
+ );
+ act(() => {
+ vi.advanceTimersByTime(150);
+ });
+ expect(trigger).toHaveAttribute('aria-expanded', 'true');
+ act(() => {
+ vi.advanceTimersByTime(100);
+ });
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
+
+ vi.useRealTimers();
+ });
+
+ it('waits the `delay` it is given before a hover opens the flyout', async () => {
+ vi.useFakeTimers({shouldAdvanceTime: true});
+ const user = userEvent.setup({advanceTimers: vi.advanceTimersByTime});
+ render(<TimedMoveMenu delay={1000} />);
+
+ await user.click(screen.getByRole('button', {name: /Actions/}));
+ const trigger = screen.getByRole('menuitem', {
+ name: /Move to/,
+ hidden: true,
+ });
+ await user.hover(trigger);
+ act(() => {
+ vi.advanceTimersByTime(500);
+ });
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
+ act(() => {
+ vi.advanceTimersByTime(700);
+ });
+ expect(trigger).toHaveAttribute('aria-expanded', 'true');
+
+ vi.useRealTimers();
+ });
+
+ it('keeps the flyout open for the `hideDelay` it is given after the pointer leaves', async () => {
+ vi.useFakeTimers({shouldAdvanceTime: true});
+ const user = userEvent.setup({advanceTimers: vi.advanceTimersByTime});
+ render(<TimedMoveMenu hideDelay={1000} />);
+
+ await user.click(screen.getByRole('button', {name: /Actions/}));
+ const trigger = screen.getByRole('menuitem', {
+ name: /Move to/,
+ hidden: true,
+ });
+ await user.hover(trigger);
+ act(() => {
+ vi.advanceTimersByTime(300);
+ });
+ expect(trigger).toHaveAttribute('aria-expanded', 'true');
+
+ await user.hover(
+ screen.getByRole('menuitem', {name: 'Rename', hidden: true}),
+ );
+ act(() => {
+ vi.advanceTimersByTime(500);
+ });
+ expect(trigger).toHaveAttribute('aria-expanded', 'true');
+ act(() => {
+ vi.advanceTimersByTime(700);
+ });
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
+
+ vi.useRealTimers();
+ });
+});
+
describe('DropdownMenuSubMenu hover/click guard', () => {
it('keeps the flyout open when a hover-open is immediately clicked', async () => {
vi.useFakeTimers({shouldAdvanceTime: true});
diff --git a/packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsx b/packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsx
index 178a298733..f1abc419b2 100644
--- a/packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsx
+++ b/packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsx
@@ -376,6 +376,17 @@ interface DropdownMenuSubMenuBaseProps extends Omit<
* @default 'adaptive'
*/
presentation?: DropdownMenuSubMenuPresentation;
+ /**
+ * How long a hovering pointer waits before the flyout opens, in
+ * milliseconds. Keyboard focus and touch never wait.
+ * @default 150
+ */
+ delay?: number;
+ /**
+ * How long the flyout stays open after the pointer leaves, in milliseconds.
+ * @default 200
+ */
+ hideDelay?: number;
/**
* Content above the sub-menu's rows: a field that filters them, say. Like
* the root menu's `header`, it sits beside the sub-menu's `role="menu"`
@@ -495,6 +506,8 @@ export function DropdownMenuSubMenu(
menuWidth,
onOpenChange,
presentation = 'adaptive',
+ delay = 150,
+ hideDelay = 200,
header,
footer,
children,
@@ -708,6 +721,8 @@ export function DropdownMenuSubMenu(
hide: hideLayer,
isOpen: isFlyoutOpen,
isEnabled: canOpen && !isDrillIn && isRootMenuOpen,
+ showDelay: delay,
+ hideDelay,
// The safe triangle toward the flyout's near edge is built from the
// flyout this component renders, not the hook's own list ref: the
// frame, with a header or footer.