Skip to content

Commit eef7fe0

Browse files
committed
MenubarSubmenu: add enum for menubar list item roles
1 parent 4e993cf commit eef7fe0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

client/components/Menubar/MenubarSubmenu.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ export enum MenuContainerRole {
2323
LISTBOX = 'listbox'
2424
}
2525

26+
/** Custom subset of valid roles for the Menubar items */
27+
export enum MenubarListItemRole {
28+
MENUITEM = 'menuitem',
29+
OPTION = 'option'
30+
}
31+
2632
/* -------------------------------------------------------------------------------------------------
2733
* useMenuProps hook
2834
* -----------------------------------------------------------------------------------------------*/
@@ -58,7 +64,7 @@ interface MenubarTriggerProps
5864
'aria-haspopup' | 'aria-expanded' | 'onMouseEnter' | 'onKeyDown' | 'role'
5965
> {
6066
/** The ARIA role of the trigger button */
61-
role?: string;
67+
role?: MenubarListItemRole;
6268
/** The ARIA property that indicates the presence of a popup */
6369
hasPopup?: MenubarTriggerAriaHasPopup;
6470
}
@@ -85,7 +91,11 @@ interface MenubarTriggerProps
8591
*/
8692
const MenubarTrigger = React.forwardRef<HTMLButtonElement, MenubarTriggerProps>(
8793
(
88-
{ role = 'menuitem', hasPopup = MenubarTriggerAriaHasPopup.MENU, ...props },
94+
{
95+
role = MenubarListItemRole.MENUITEM,
96+
hasPopup = MenubarTriggerAriaHasPopup.MENU,
97+
...props
98+
},
8999
ref
90100
) => {
91101
const {
@@ -227,7 +237,7 @@ export interface MenubarSubmenuProps {
227237
/** The title of the submenu */
228238
title: string;
229239
/** The ARIA role of the trigger button */
230-
triggerRole?: string;
240+
triggerRole?: MenubarListItemRole;
231241
/** The ARIA role of the list element */
232242
listRole?: MenuContainerRole;
233243
}
@@ -249,7 +259,7 @@ export function MenubarSubmenu({
249259
children,
250260
id,
251261
title,
252-
triggerRole = 'menuitem',
262+
triggerRole = MenubarListItemRole.MENUITEM,
253263
listRole = MenuContainerRole.MENU,
254264
...props
255265
}: MenubarSubmenuProps) {

0 commit comments

Comments
 (0)