Skip to content

Commit

Permalink
Add default value for disabled prop
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Dec 20, 2024
1 parent 6b15b98 commit a6d5fc1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/components/src/menu/checkbox-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const MenuCheckboxItem = forwardRef<
HTMLDivElement,
WordPressComponentProps< MenuCheckboxItemProps, 'div', false >
>( function MenuCheckboxItem(
{ suffix, children, hideOnClick = false, ...props },
{ suffix, children, disabled = false, hideOnClick = false, ...props },
ref
) {
const menuContext = useContext( MenuContext );
Expand All @@ -37,6 +37,7 @@ export const MenuCheckboxItem = forwardRef<
ref={ ref }
{ ...props }
accessibleWhenDisabled
disabled={ disabled }
hideOnClick={ hideOnClick }
store={ menuContext.store }
>
Expand Down
11 changes: 10 additions & 1 deletion packages/components/src/menu/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ export const MenuItem = forwardRef<
HTMLDivElement,
WordPressComponentProps< MenuItemProps, 'div', false >
>( function MenuItem(
{ prefix, suffix, children, hideOnClick = true, store, ...props },
{
prefix,
suffix,
children,
disabled = false,
hideOnClick = true,
store,
...props
},
ref
) {
const menuContext = useContext( MenuContext );
Expand All @@ -37,6 +45,7 @@ export const MenuItem = forwardRef<
ref={ ref }
{ ...props }
accessibleWhenDisabled
disabled={ disabled }
hideOnClick={ hideOnClick }
store={ computedStore }
>
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/menu/radio-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const MenuRadioItem = forwardRef<
HTMLDivElement,
WordPressComponentProps< MenuRadioItemProps, 'div', false >
>( function MenuRadioItem(
{ suffix, children, hideOnClick = false, ...props },
{ suffix, children, disabled = false, hideOnClick = false, ...props },
ref
) {
const menuContext = useContext( MenuContext );
Expand All @@ -44,6 +44,7 @@ export const MenuRadioItem = forwardRef<
ref={ ref }
{ ...props }
accessibleWhenDisabled
disabled={ disabled }
hideOnClick={ hideOnClick }
store={ menuContext.store }
>
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/menu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface MenuProps {
*
* Note: this prop will be overridden by the `open` prop if it is
* provided (meaning the component will be used in "controlled" mode).
*
* @default false
*/
defaultOpen?: Ariakit.MenuProviderProps[ 'defaultOpen' ];
Expand Down Expand Up @@ -186,6 +187,8 @@ export interface MenuItemProps {
* Determines if the element is disabled. This sets the `aria-disabled`
* attribute accordingly, enabling support for all elements, including those
* that don't support the native `disabled` attribute.
*
* @default false
*/
disabled?: Ariakit.MenuItemProps[ 'disabled' ];
/**
Expand Down Expand Up @@ -227,6 +230,8 @@ export interface MenuCheckboxItemProps {
* Determines if the element is disabled. This sets the `aria-disabled`
* attribute accordingly, enabling support for all elements, including those
* that don't support the native `disabled` attribute.
*
* @default false
*/
disabled?: Ariakit.MenuItemCheckboxProps[ 'disabled' ];
/**
Expand Down Expand Up @@ -289,6 +294,8 @@ export interface MenuRadioItemProps {
* Determines if the element is disabled. This sets the `aria-disabled`
* attribute accordingly, enabling support for all elements, including those
* that don't support the native `disabled` attribute.
*
* @default false
*/
disabled?: Ariakit.MenuItemRadioProps[ 'disabled' ];
/**
Expand Down

0 comments on commit a6d5fc1

Please sign in to comment.