Skip to content

Commit

Permalink
Remove initialSortedRow prop
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Aug 28, 2024
1 parent 540d8f8 commit 79a2487
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 41 deletions.
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 `secondary` 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

0 comments on commit 79a2487

Please sign in to comment.