Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the deprecated initialSortedRow Table prop #2658

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/late-feet-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sumup-oss/circuit-ui": major
---

Removed the Table component's deprecated `initialSortedRow` prop. Use the `initialSortedColumn` prop instead.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const NotificationBanner = forwardRef<
) {
deprecate(
'NotificationBanner',
"The action's `tertiary` variant has been deprecated. Use the `primary` size instead.",
"The action's `tertiary` variant has been deprecated. Use the `primary` variant instead.",
);
}

Expand Down
24 changes: 0 additions & 24 deletions packages/circuit-ui/components/Table/Table.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,30 +134,6 @@ describe('Table', () => {
});
});

it('should sort a column in ascending order when initial sort direction and initial sorted row is provided and console.warn about it', () => {
const warnMock = vi.spyOn(console, 'warn');

render(
<Table
rows={rows}
headers={headers}
rowHeaders={false}
initialSortedRow={1}
initialSortDirection={'ascending'}
/>,
);

const cellEls = screen.getAllByRole('cell');

const sortedRow = ['a', 'c', 'b'];

rows.forEach((_row, index) => {
const cellIndex = rowLength * index;
expect(cellEls[cellIndex]).toHaveTextContent(sortedRow[index]);
});
expect(warnMock).toHaveBeenCalled();
});

it('should sort a column in descending order', async () => {
render(<Table rows={rows} headers={headers} rowHeaders={false} />);

Expand Down
18 changes: 2 additions & 16 deletions packages/circuit-ui/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { Component, createRef, type HTMLAttributes, type UIEvent } from 'react';
import { isNil } from '../../util/type-check.js';
import { throttle } from '../../util/helpers.js';
import { clsx } from '../../styles/clsx.js';
import { deprecate } from '../../util/logger.js';

import { TableHead } from './components/TableHead/index.js';
import { TableBody } from './components/TableBody/index.js';
Expand Down Expand Up @@ -68,12 +67,6 @@ export interface TableProps extends HTMLAttributes<HTMLDivElement> {
* Specifies the initial sort order of the table
*/
initialSortDirection?: 'ascending' | 'descending';
/**
* @deprecated
*
* Use the `initialSortedColumn` prop instead.
*/
initialSortedRow?: number;
/**
* Specifies the column index which `initialSortDirection` will be applied to
*/
Expand Down Expand Up @@ -104,19 +97,12 @@ type TableState = {
export class Table extends Component<TableProps, TableState> {
constructor(props: TableProps) {
super(props);
if (process.env.NODE_ENV !== 'production' && this.props.initialSortedRow) {
deprecate(
'Table',
'The `initialSortedRow` prop has been deprecated. Use the `initialSortedColumn` prop instead.',
);
}
this.state = {
sortedColumn:
this.props.initialSortedColumn || this.props.initialSortedRow,
sortedColumn: this.props.initialSortedColumn,
rows: this.getInitialRows(
this.props.rows,
this.props.initialSortDirection,
this.props.initialSortedColumn || this.props.initialSortedRow,
this.props.initialSortedColumn,
),
sortHover: undefined,
sortDirection: this.props.initialSortDirection,
Expand Down
Loading