Skip to content

Commit

Permalink
fix(EntityTable): properly remove actions resolver when there is not …
Browse files Browse the repository at this point in the history
…entity (#2107)
  • Loading branch information
mkholjuraev authored Nov 27, 2023
1 parent 2b6439c commit 5238307
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/components/InventoryTable/EntityTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ const EntityTable = ({
direction: sortBy?.direction,
};

delete tableProps.RowWrapper;
if (rows?.length === 0) {
delete tableProps.actionResolver;
}
const modifiedTableProps = useMemo(() => {
const { RowWrapper, ...withoutRowWrapper } = tableProps;
if (rows?.length === 0) {
const { actionResolver, ...filteredTableProps } = withoutRowWrapper;

return filteredTableProps;
}
return withoutRowWrapper;
}, [rows, tableProps]);

return (
<React.Fragment>
Expand Down Expand Up @@ -130,7 +135,7 @@ const EntityTable = ({
...(actions && rows?.length > 0 && { actions }),
}}
isStickyHeader
{...tableProps}
{...modifiedTableProps}
>
<TableHeader />
<TableBody />
Expand All @@ -147,7 +152,7 @@ const EntityTable = ({
}
)}
rowSize={15}
variant={variant ?? tableProps.variant}
variant={variant ?? modifiedTableProps.variant}
isSelectable={hasCheckbox}
sortBy={tableSortBy}
/>
Expand Down

0 comments on commit 5238307

Please sign in to comment.