Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<MenuToggleElement>;
/** Value to overwrite the randomly generated data-ouia-component-id. It will always target the toggle button. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,23 @@ test(`Does not render with class ${styles.modifiers.expanded} when isExpanded is
render(<MenuToggle isExpanded>Text Expanded Toggle</MenuToggle>);
expect(screen.getByRole('button')).toHaveClass(styles.modifiers.expanded);
});

test(`Renders with aria-haspopup="true" when 'aria-haspopup' is passed and value is true`, () => {
render(<MenuToggle aria-haspopup="true">Toggle</MenuToggle>);
expect(screen.getByRole('button')).toHaveAttribute('aria-haspopup', 'true');
});

test(`Renders with aria-haspopup="false" when 'aria-haspopup' is passed and value is false`, () => {
render(<MenuToggle aria-haspopup="false">Toggle</MenuToggle>);
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(<MenuToggle aria-haspopup={true}>Toggle</MenuToggle>);
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(<MenuToggle aria-haspopup={false}>Toggle</MenuToggle>);
expect(screen.getByRole('button')).toHaveAttribute('aria-haspopup', 'false');
});
Loading