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

Add `disabled` prop to `Menu`

parent 06678e64
...@@ -51,6 +51,8 @@ export type MenuProps = { ...@@ -51,6 +51,8 @@ export type MenuProps = {
*/ */
defaultOpen?: boolean; defaultOpen?: boolean;
disabled?: boolean;
/** Whether to render an (arrow) indicator next to the Menu label */ /** Whether to render an (arrow) indicator next to the Menu label */
menuIndicator?: boolean; menuIndicator?: boolean;
...@@ -98,6 +100,7 @@ export default function Menu({ ...@@ -98,6 +100,7 @@ export default function Menu({
containerPositioned = true, containerPositioned = true,
contentClass, contentClass,
defaultOpen = false, defaultOpen = false,
disabled = false,
label, label,
open, open,
onOpenChanged, onOpenChanged,
...@@ -201,6 +204,7 @@ export default function Menu({ ...@@ -201,6 +204,7 @@ export default function Menu({
}, },
)} )}
data-testid="menu-toggle-button" data-testid="menu-toggle-button"
disabled={disabled}
onMouseDown={toggleMenu} onMouseDown={toggleMenu}
onClick={toggleMenu} onClick={toggleMenu}
aria-label={title} aria-label={title}
......
...@@ -52,6 +52,12 @@ describe('Menu', () => { ...@@ -52,6 +52,12 @@ describe('Menu', () => {
assert.isFalse(isOpen(wrapper)); 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', () => { 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 // When `open` is present, `Menu` will invoke `onOpenChanged` on interactions
// but will not modify the its open state directly. // 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