Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu granular subcomponents: Refactor dataviews item actions menu #67636

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading