Skip to content

Commit

Permalink
DataViews: Only show elligible actions in the bulk editing menu (#63473)
Browse files Browse the repository at this point in the history
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: jameskoster <[email protected]>
  • Loading branch information
3 people authored Jul 12, 2024
1 parent 1b7e3a7 commit b4da8fc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/dataviews/src/bulk-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ function BulkActionItem< Item >( {
return (
<DropdownMenuItem
key={ action.id }
disabled={ eligibleItems.length === 0 }
hideOnClick={ ! shouldShowModal }
onClick={ async () => {
if ( shouldShowModal ) {
Expand All @@ -142,9 +141,7 @@ function BulkActionItem< Item >( {
action.callback( eligibleItems, { registry } );
}
} }
suffix={
eligibleItems.length > 0 ? eligibleItems.length : undefined
}
suffix={ eligibleItems.length }
>
{ action.label }
</DropdownMenuItem>
Expand All @@ -156,10 +153,18 @@ function ActionsMenuGroup< Item >( {
selectedItems,
setActionWithModal,
}: ActionsMenuGroupProps< Item > ) {
const elligibleActions = useMemo( () => {
return actions.filter( ( action ) => {
return selectedItems.some(
( item ) => ! action.isEligible || action.isEligible( item )
);
} );
}, [ actions, selectedItems ] );

return (
<>
<DropdownMenuGroup>
{ actions.map( ( action ) => (
{ elligibleActions.map( ( action ) => (
<BulkActionItem
key={ action.id }
action={ action }
Expand Down

1 comment on commit b4da8fc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in b4da8fc.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9907304137
📝 Reported issues:

Please sign in to comment.