Skip to content

Commit

Permalink
Refactor dataviews item actions menu (#67636)
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo authored Dec 11, 2024
1 parent 639be02 commit 6078c61
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions packages/dataviews/src/components/dataviews-item-actions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ interface ActionsListProps< Item > {
ActionTrigger: ( props: ActionTriggerProps< Item > ) => ReactElement;
}

function ButtonTrigger< Item >( {
function ActionButtonTrigger< Item >( {
action,
onClick,
items,
Expand All @@ -90,7 +90,7 @@ function ButtonTrigger< Item >( {
);
}

function MenuItemTrigger< Item >( {
function ActionMenuItemTrigger< Item >( {
action,
onClick,
items,
Expand Down Expand Up @@ -170,7 +170,7 @@ export function ActionsMenuGroup< Item >( {
actions={ actions }
item={ item }
registry={ registry }
ActionTrigger={ MenuItemTrigger }
ActionTrigger={ ActionMenuItemTrigger }
/>
</Menu.Group>
);
Expand Down Expand Up @@ -250,20 +250,22 @@ function CompactItemActions< Item >( {
isSmall,
}: CompactItemActionsProps< Item > ) {
return (
<Menu
trigger={
<Button
size={ isSmall ? 'small' : 'compact' }
icon={ moreVertical }
label={ __( 'Actions' ) }
accessibleWhenDisabled
disabled={ ! actions.length }
className="dataviews-all-actions-button"
/>
}
placement="bottom-end"
>
<ActionsMenuGroup actions={ actions } item={ item } />
<Menu placement="bottom-end">
<Menu.TriggerButton
render={
<Button
size={ isSmall ? 'small' : 'compact' }
icon={ moreVertical }
label={ __( 'Actions' ) }
accessibleWhenDisabled
disabled={ ! actions.length }
className="dataviews-all-actions-button"
/>
}
/>
<Menu.Popover>
<ActionsMenuGroup actions={ actions } item={ item } />
</Menu.Popover>
</Menu>
);
}
Expand All @@ -281,7 +283,7 @@ function PrimaryActions< Item >( {
actions={ actions }
item={ item }
registry={ registry }
ActionTrigger={ ButtonTrigger }
ActionTrigger={ ActionButtonTrigger }
/>
);
}
Expand Down

0 comments on commit 6078c61

Please sign in to comment.