From 5238307c8278270cfde8f6751c981a7e2a6fe332 Mon Sep 17 00:00:00 2001 From: Muslimjon <59481011+mkholjuraev@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:15:59 +0100 Subject: [PATCH] fix(EntityTable): properly remove actions resolver when there is not entity (#2107) --- src/components/InventoryTable/EntityTable.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/InventoryTable/EntityTable.js b/src/components/InventoryTable/EntityTable.js index 432a6bfdb..0f69398f3 100644 --- a/src/components/InventoryTable/EntityTable.js +++ b/src/components/InventoryTable/EntityTable.js @@ -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 ( @@ -130,7 +135,7 @@ const EntityTable = ({ ...(actions && rows?.length > 0 && { actions }), }} isStickyHeader - {...tableProps} + {...modifiedTableProps} > @@ -147,7 +152,7 @@ const EntityTable = ({ } )} rowSize={15} - variant={variant ?? tableProps.variant} + variant={variant ?? modifiedTableProps.variant} isSelectable={hasCheckbox} sortBy={tableSortBy} />