Skip to content

Commit

Permalink
Remove isExpandable prop from basic/memory tables
Browse files Browse the repository at this point in the history
- will automatically be calculated if `itemIdToExpandedRowMap` exists, prop is no longer needed
  • Loading branch information
cee-chen committed Mar 28, 2024
1 parent 0b13d3b commit 8f860f1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ export default () => {
items={pageOfItems}
itemId="id"
itemIdToExpandedRowMap={itemIdToExpandedRowMap}
isExpandable={true}
columns={columnsWithExpandingRowToggle}
pagination={pagination}
sorting={sorting}
Expand Down
1 change: 0 additions & 1 deletion src/components/basic_table/basic_table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ describe('EuiBasicTable', () => {
itemIdToExpandedRowMap: {
'1': <div>Expanded row</div>,
},
isExpandable: true,
};
const { getByText } = render(<EuiBasicTable {...props} />);

Expand Down
17 changes: 5 additions & 12 deletions src/components/basic_table/basic_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ interface BasicTableProps<T extends object>
* 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
*/
Expand Down Expand Up @@ -523,7 +522,6 @@ export class EuiBasicTable<T extends object = any> extends Component<
itemIdToExpandedRowMap,
responsive,
responsiveBreakpoint,
isExpandable,
rowProps,
cellProps,
tableCaption,
Expand Down Expand Up @@ -972,13 +970,8 @@ export class EuiBasicTable<T extends object = any> extends Component<
}

renderItemRow(item: T, rowIndex: number) {
const {
columns,
selection,
rowHeader,
itemIdToExpandedRowMap = {},
isExpandable,
} = this.props;
const { columns, selection, rowHeader, itemIdToExpandedRowMap } =
this.props;

const cells = [];

Expand Down Expand Up @@ -1053,7 +1046,7 @@ export class EuiBasicTable<T extends object = any> 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;
Expand All @@ -1064,7 +1057,7 @@ export class EuiBasicTable<T extends object = any> extends Component<
hasSelection={!!selection}
>
<EuiTableRowCell colSpan={expandedRowColSpan} textOnly={false}>
{itemIdToExpandedRowMap[itemId]}
{itemIdToExpandedRowMap![itemId]}
</EuiTableRowCell>
</EuiTableRow>
) : undefined;
Expand All @@ -1078,7 +1071,7 @@ export class EuiBasicTable<T extends object = any> extends Component<
isSelectable={!rowSelectionDisabled}
isSelected={selected}
hasActions={hasActions}
isExpandable={isExpandable}
isExpandable={hasExpandedRow}
{...rowProps}
>
{cells}
Expand Down

0 comments on commit 8f860f1

Please sign in to comment.