diff --git a/packages/react-core/src/components/MenuToggle/MenuToggle.tsx b/packages/react-core/src/components/MenuToggle/MenuToggle.tsx index 73646fd7df8..865decd1ab1 100644 --- a/packages/react-core/src/components/MenuToggle/MenuToggle.tsx +++ b/packages/react-core/src/components/MenuToggle/MenuToggle.tsx @@ -72,7 +72,7 @@ export interface MenuToggleProps /** Adds styling which affects the size of the menu toggle */ size?: 'default' | 'sm'; /** Indicates what type of popup will be triggered by the menu toggle. A value of true is the same as a value of "menu". */ - 'aria-haspopup'?: 'menu' | 'listbox' | boolean; + 'aria-haspopup'?: 'menu' | 'listbox' | 'true' | 'false' | boolean; /** @hide Forwarded ref */ innerRef?: React.Ref; /** Value to overwrite the randomly generated data-ouia-component-id. It will always target the toggle button. */ diff --git a/packages/react-core/src/components/MenuToggle/__tests__/MenuToggle.test.tsx b/packages/react-core/src/components/MenuToggle/__tests__/MenuToggle.test.tsx index fcc73760821..a47dee80e9a 100644 --- a/packages/react-core/src/components/MenuToggle/__tests__/MenuToggle.test.tsx +++ b/packages/react-core/src/components/MenuToggle/__tests__/MenuToggle.test.tsx @@ -184,3 +184,23 @@ test(`Does not render with class ${styles.modifiers.expanded} when isExpanded is render(Text Expanded Toggle); expect(screen.getByRole('button')).toHaveClass(styles.modifiers.expanded); }); + +test(`Renders with aria-haspopup="true" when 'aria-haspopup' is passed and value is true`, () => { + render(Toggle); + expect(screen.getByRole('button')).toHaveAttribute('aria-haspopup', 'true'); +}); + +test(`Renders with aria-haspopup="false" when 'aria-haspopup' is passed and value is false`, () => { + render(Toggle); + expect(screen.getByRole('button')).toHaveAttribute('aria-haspopup', 'false'); +}); + +test(`Renders with aria-haspopup="true" when 'aria-haspopup' is passed a boolean with a value of true`, () => { + render(Toggle); + expect(screen.getByRole('button')).toHaveAttribute('aria-haspopup', 'true'); +}); + +test(`Renders with aria-haspopup="false" when 'aria-haspopup' is passed a boolean with a value of false`, () => { + render(Toggle); + expect(screen.getByRole('button')).toHaveAttribute('aria-haspopup', 'false'); +});