Skip to content

Commit

Permalink
revert Table page return 1 after sort
Browse files Browse the repository at this point in the history
close #16978
close #17770
close #17648
close #18099
close #17075
close #19369
  • Loading branch information
afc163 committed Dec 28, 2019
1 parent 670bd4b commit 2c10e9e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
8 changes: 0 additions & 8 deletions components/table/Table.tsx
Expand Up @@ -868,7 +868,6 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
};

toggleSortOrder(column: ColumnProps<T>) {
const pagination = { ...this.state.pagination };
const sortDirections = column.sortDirections || (this.props.sortDirections as SortOrder[]);
const { sortOrder, sortColumn } = this.state;
// 只同时允许一列进行排序,否则会导致排序顺序的逻辑问题
Expand All @@ -883,14 +882,7 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
newSortOrder = sortDirections[0];
}

if (this.props.pagination) {
// Reset current prop
pagination.current = 1;
pagination.onChange!(pagination.current);
}

const newState = {
pagination,
sortOrder: newSortOrder,
sortColumn: newSortOrder ? column : null,
};
Expand Down
5 changes: 3 additions & 2 deletions components/table/__tests__/Table.sorter.test.js
Expand Up @@ -613,15 +613,16 @@ describe('Table.sorter', () => {
createTable({
pagination: {
pageSize: 2,
defaultCurrent: 2,
onChange: onPageChange,
},
onChange,
}),
);

wrapper.find('.ant-table-column-sorters').simulate('click');
expect(onChange.mock.calls[0][0].current).toBe(1);
expect(onPageChange.mock.calls[0][0]).toBe(1);
expect(onChange.mock.calls[0][0].current).toBe(2);
expect(onPageChange).not.toHaveBeenCalled();
});

it('should support onHeaderCell in sort column', () => {
Expand Down

0 comments on commit 2c10e9e

Please sign in to comment.