Commit 261d0cd8 authored by Robert Knight's avatar Robert Knight

Add `disabled` prop to `Menu`

parent 06678e64
......@@ -51,6 +51,8 @@ export type MenuProps = {
*/
defaultOpen?: boolean;
disabled?: boolean;
/** Whether to render an (arrow) indicator next to the Menu label */
menuIndicator?: boolean;
......@@ -98,6 +100,7 @@ export default function Menu({
containerPositioned = true,
contentClass,
defaultOpen = false,
disabled = false,
label,
open,
onOpenChanged,
......@@ -201,6 +204,7 @@ export default function Menu({
},
)}
data-testid="menu-toggle-button"
disabled={disabled}
onMouseDown={toggleMenu}
onClick={toggleMenu}
aria-label={title}
......
......@@ -52,6 +52,12 @@ describe('Menu', () => {
assert.isFalse(isOpen(wrapper));
});
it('disables menu if `disabled` prop is true', () => {
const wrapper = createMenu({ disabled: true });
const toggle = wrapper.find(toggleSelector);
assert.isTrue(toggle.prop('disabled'));
});
it('leaves the management of open/closed state to parent component if `open` prop present', () => {
// When `open` is present, `Menu` will invoke `onOpenChanged` on interactions
// but will not modify the its open state directly.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment