Skip to content

Commit

Permalink
[EuiTable][EuiBasicTable][EuiInMemoryTable] Remove responsive prop …
Browse files Browse the repository at this point in the history
…completely in favor of `responsiveBreakpoint` (#7633)
  • Loading branch information
cee-chen committed Apr 1, 2024
1 parent 981ad1e commit c23f308
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 36 deletions.
7 changes: 5 additions & 2 deletions changelogs/upcoming/7625.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
- Updated `EuiTable`, `EuiBasicTable`, and `EuiInMemoryTable` with a new `responsiveBreakpoint` prop, which allows customizing the point at which the table collapses into a mobile-friendly view with cards
- Updated `EuiProvider`'s `componentDefaults` prop to allow configuring `EuiTable.responsiveBreakpoint`

**Deprecations**
**Breaking changes**

- Removed the `responsive` prop from `EuiTable`, `EuiBasicTable`, and `EuiInMemoryTable`. Use the new `responsiveBreakpoint` prop instead

**DOM changes**

- Deprecated the `responsive` prop from `EuiTable`, `EuiBasicTable`, and `EuiInMemoryTable`. Use the new `responsiveBreakpoint` prop instead
- `EuiTable` mobile headers no longer render in the DOM when not visible (previously rendered with `display: none`). This may affect DOM testing assertions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`EuiBasicTable renders (bare-bones) 1`] = `
data-test-subj="test subject string"
>
<table
class="euiTable euiTable--responsive emotion-euiTable-fixed-uncompressed-desktop"
class="euiTable emotion-euiTable-fixed-uncompressed-desktop"
id="__table_generated-id"
tabindex="-1"
>
Expand Down Expand Up @@ -119,7 +119,7 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin
class="euiBasicTable"
>
<table
class="euiTable euiTable--responsive emotion-euiTable-fixed-uncompressed-desktop"
class="euiTable emotion-euiTable-fixed-uncompressed-desktop"
id="__table_generated-id"
tabindex="-1"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ exports[`EuiInMemoryTable empty array 1`] = `
data-test-subj="test subject string"
>
<table
class="euiTable euiTable--responsive emotion-euiTable-fixed-uncompressed-desktop"
class="euiTable emotion-euiTable-fixed-uncompressed-desktop"
id="__table_generated-id"
tabindex="-1"
>
Expand Down Expand Up @@ -236,7 +236,6 @@ exports[`EuiInMemoryTable with executeQueryOptions 1`] = `
/>
}
onChange={[Function]}
responsive={true}
tableLayout="fixed"
/>
`;
Expand All @@ -248,7 +247,7 @@ exports[`EuiInMemoryTable with items 1`] = `
data-test-subj="test subject string"
>
<table
class="euiTable euiTable--responsive emotion-euiTable-fixed-uncompressed-desktop"
class="euiTable emotion-euiTable-fixed-uncompressed-desktop"
id="__table_generated-id"
tabindex="-1"
>
Expand Down
23 changes: 6 additions & 17 deletions src/components/basic_table/basic_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ export class EuiBasicTable<T extends object = any> extends Component<
declare context: ContextType<typeof EuiComponentDefaultsContext>;

static defaultProps = {
responsive: true,
tableLayout: 'fixed',
noItemsMessage: (
<EuiI18n token="euiBasicTable.noItemsMessage" default="No items found" />
Expand Down Expand Up @@ -523,7 +522,6 @@ export class EuiBasicTable<T extends object = any> extends Component<
noItemsMessage,
compressed,
itemIdToExpandedRowMap,
responsive,
responsiveBreakpoint,
isSelectable,
isExpandable,
Expand Down Expand Up @@ -554,28 +552,19 @@ export class EuiBasicTable<T extends object = any> extends Component<
}

renderTable() {
const {
compressed,
responsive,
responsiveBreakpoint,
tableLayout,
loading,
} = this.props;
const { compressed, responsiveBreakpoint, tableLayout, loading } =
this.props;

return (
<>
{/* TODO: Remove conditional once `responsive` prop is deprecated */}
{responsive && (
<EuiTableHeaderMobile responsiveBreakpoint={responsiveBreakpoint}>
{this.renderSelectAll(true)}
{this.renderTableMobileSort()}
</EuiTableHeaderMobile>
)}
<EuiTableHeaderMobile responsiveBreakpoint={responsiveBreakpoint}>
{this.renderSelectAll(true)}
{this.renderTableMobileSort()}
</EuiTableHeaderMobile>
<EuiTable
id={this.tableId}
tableLayout={tableLayout}
responsiveBreakpoint={responsiveBreakpoint}
responsive={responsive}
compressed={compressed}
css={loading && safariLoadingWorkaround}
>
Expand Down
1 change: 0 additions & 1 deletion src/components/basic_table/in_memory_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ export class EuiInMemoryTable<T extends object = object> extends Component<
static contextType = EuiComponentDefaultsContext;

static defaultProps = {
responsive: true,
tableLayout: 'fixed',
searchFormat: 'eql',
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/table/__snapshots__/table.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`EuiTable renders 1`] = `
<table
aria-label="aria-label"
class="euiTable testClass1 testClass2 euiTable--responsive emotion-euiTable-fixed-uncompressed-desktop-euiTestCss"
class="euiTable testClass1 testClass2 emotion-euiTable-fixed-uncompressed-desktop-euiTestCss"
data-test-subj="test subject string"
tabindex="-1"
>
Expand Down
12 changes: 2 additions & 10 deletions src/components/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export interface EuiTableProps
extends CommonProps,
TableHTMLAttributes<HTMLTableElement> {
compressed?: boolean;
/**
* @deprecated - use `responsiveBreakpoint` instead
*/
responsive?: boolean;
/**
* Named breakpoint. Below this size, the table will collapse
* into responsive cards.
Expand All @@ -48,15 +44,11 @@ export const EuiTable: FunctionComponent<EuiTableProps> = ({
compressed,
tableLayout = 'fixed',
responsiveBreakpoint, // Default handled by `useIsEuiTableResponsive`
responsive = true,
...rest
}) => {
const isResponsive =
useIsEuiTableResponsive(responsiveBreakpoint) && responsive;
const isResponsive = useIsEuiTableResponsive(responsiveBreakpoint);

const classes = classNames('euiTable', className, {
'euiTable--responsive': responsive,
});
const classes = classNames('euiTable', className);

const styles = useEuiMemoizedStyles(euiTableStyles);
const cssStyles = [
Expand Down

0 comments on commit c23f308

Please sign in to comment.