From d9f18e5561b6233f69d82fff65c9cf8488227572 Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Fri, 20 Dec 2024 18:58:06 +0200 Subject: [PATCH] DataViews: Don't render actions dropdown when all eligible ones are `primary` (#68168) Co-authored-by: ntsekouras Co-authored-by: mcsf Co-authored-by: oandregal --- .../src/components/dataviews-item-actions/index.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/dataviews/src/components/dataviews-item-actions/index.tsx b/packages/dataviews/src/components/dataviews-item-actions/index.tsx index f849eca7c783f0..0031663ea10e78 100644 --- a/packages/dataviews/src/components/dataviews-item-actions/index.tsx +++ b/packages/dataviews/src/components/dataviews-item-actions/index.tsx @@ -145,13 +145,6 @@ export function ActionsMenuGroup< Item >( { ); } -function hasOnlyOneActionAndIsPrimary< Item >( - primaryActions: Action< Item >[], - actions: Action< Item >[] -) { - return primaryActions.length === 1 && actions.length === 1; -} - export default function ItemActions< Item >( { item, actions, @@ -184,7 +177,8 @@ export default function ItemActions< Item >( { ); } - if ( hasOnlyOneActionAndIsPrimary( primaryActions, actions ) ) { + // If all actions are primary, there is no need to render the dropdown. + if ( primaryActions.length === eligibleActions.length ) { return (