From 8f860f174dc1bfd227496855077b97ea17dde14e Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Thu, 28 Mar 2024 14:03:49 -0700 Subject: [PATCH] Remove `isExpandable` prop from basic/memory tables - will automatically be calculated if `itemIdToExpandedRowMap` exists, prop is no longer needed --- .../tables/expanding_rows/expanding_rows.tsx | 1 - src/components/basic_table/basic_table.test.tsx | 1 - src/components/basic_table/basic_table.tsx | 17 +++++------------ 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src-docs/src/views/tables/expanding_rows/expanding_rows.tsx b/src-docs/src/views/tables/expanding_rows/expanding_rows.tsx index b17130aa2d1d..faa1f0191789 100644 --- a/src-docs/src/views/tables/expanding_rows/expanding_rows.tsx +++ b/src-docs/src/views/tables/expanding_rows/expanding_rows.tsx @@ -260,7 +260,6 @@ export default () => { items={pageOfItems} itemId="id" itemIdToExpandedRowMap={itemIdToExpandedRowMap} - isExpandable={true} columns={columnsWithExpandingRowToggle} pagination={pagination} sorting={sorting} diff --git a/src/components/basic_table/basic_table.test.tsx b/src/components/basic_table/basic_table.test.tsx index bf9513474ff4..43893d8c5cb6 100644 --- a/src/components/basic_table/basic_table.test.tsx +++ b/src/components/basic_table/basic_table.test.tsx @@ -224,7 +224,6 @@ describe('EuiBasicTable', () => { itemIdToExpandedRowMap: { '1':
Expanded row
, }, - isExpandable: true, }; const { getByText } = render(); diff --git a/src/components/basic_table/basic_table.tsx b/src/components/basic_table/basic_table.tsx index 8e1deeb0fbe2..46c551ebddbc 100644 --- a/src/components/basic_table/basic_table.tsx +++ b/src/components/basic_table/basic_table.tsx @@ -241,7 +241,6 @@ interface BasicTableProps * Indicates which column should be used as the identifying cell in each row. Should match a "field" prop in FieldDataColumn */ rowHeader?: string; - isExpandable?: boolean; /** * Provides an infinite loading indicator */ @@ -523,7 +522,6 @@ export class EuiBasicTable extends Component< itemIdToExpandedRowMap, responsive, responsiveBreakpoint, - isExpandable, rowProps, cellProps, tableCaption, @@ -972,13 +970,8 @@ export class EuiBasicTable extends Component< } renderItemRow(item: T, rowIndex: number) { - const { - columns, - selection, - rowHeader, - itemIdToExpandedRowMap = {}, - isExpandable, - } = this.props; + const { columns, selection, rowHeader, itemIdToExpandedRowMap } = + this.props; const cells = []; @@ -1053,7 +1046,7 @@ export class EuiBasicTable extends Component< expandedRowColSpan = expandedRowColSpan - mobileOnlyCols; // We'll use the ID to associate the expanded row with the original. - const hasExpandedRow = itemIdToExpandedRowMap.hasOwnProperty(itemId); + const hasExpandedRow = itemIdToExpandedRowMap?.hasOwnProperty(itemId); const expandedRowId = hasExpandedRow ? `row_${itemId}_expansion` : undefined; @@ -1064,7 +1057,7 @@ export class EuiBasicTable extends Component< hasSelection={!!selection} > - {itemIdToExpandedRowMap[itemId]} + {itemIdToExpandedRowMap![itemId]} ) : undefined; @@ -1078,7 +1071,7 @@ export class EuiBasicTable extends Component< isSelectable={!rowSelectionDisabled} isSelected={selected} hasActions={hasActions} - isExpandable={isExpandable} + isExpandable={hasExpandedRow} {...rowProps} > {cells}