From 274591374c2cc7df365f7a8b27a62422221b6acc Mon Sep 17 00:00:00 2001 From: Matt Gallo Date: Tue, 9 May 2023 14:01:26 -0400 Subject: [PATCH] chore: shouldHideMenuItem works with less than 3 row actions (#2967) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../src/components/Datagrid/useActionsColumn.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/cloud-cognitive/src/components/Datagrid/useActionsColumn.js b/packages/cloud-cognitive/src/components/Datagrid/useActionsColumn.js index 0af2c44ddb..31634c1a97 100644 --- a/packages/cloud-cognitive/src/components/Datagrid/useActionsColumn.js +++ b/packages/cloud-cognitive/src/components/Datagrid/useActionsColumn.js @@ -44,7 +44,20 @@ const useActionsColumn = (hooks) => { style={{ display: 'flex' }} > {rowActions.map((action, index) => { - const { id, itemText, onClick, icon, ...rest } = action; + const { + id, + itemText, + onClick, + icon, + shouldHideMenuItem, + ...rest + } = action; + const hidden = + typeof shouldHideMenuItem === 'function' && + shouldHideMenuItem(row); + if (hidden) { + return null; + } const selectedRowId = selectedFlatRows?.filter((item) => item.id === row.id ? item.id : null );