Skip to content

Commit

Permalink
Add render and store props to the menu item component
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Oct 25, 2024
1 parent a887654 commit edac41f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/components/src/dropdown-menu-v2/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const DropdownMenuItem = forwardRef<
HTMLDivElement,
WordPressComponentProps< DropdownMenuItemProps, 'div', false >
>( function DropdownMenuItem(
{ prefix, suffix, children, onBlur, hideOnClick = true, ...props },
{ prefix, suffix, children, onBlur, hideOnClick = true, store, ...props },
ref
) {
// TODO: Remove when https://github.com/ariakit/ariakit/issues/4083 is fixed
Expand All @@ -28,14 +28,17 @@ export const DropdownMenuItem = forwardRef<
'DropdownMenu.Item can only be rendered inside a DropdownMenu component'
);
}

const computedStore = store ?? dropdownMenuContext.store;

return (
<Styled.DropdownMenuItem
ref={ ref }
{ ...props }
{ ...focusVisibleFixProps }
accessibleWhenDisabled
hideOnClick={ hideOnClick }
store={ dropdownMenuContext?.store }
store={ computedStore }
>
<Styled.ItemPrefixWrapper>{ prefix }</Styled.ItemPrefixWrapper>

Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/dropdown-menu-v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ export interface DropdownMenuItemProps {
* Determines if the element is disabled.
*/
disabled?: boolean;

render?: Ariakit.MenuItemProps[ 'render' ];
/**
* @ignore
*/
store?: Ariakit.MenuItemProps[ 'store' ];
}

export interface DropdownMenuCheckboxItemProps
Expand Down

0 comments on commit edac41f

Please sign in to comment.