revert Table page return 1 after sort (#20507)

close #16978
close #17770
close #17648
close #18099
close #17075
close #19369
This commit is contained in:
偏右 2019-12-28 21:52:09 +08:00 committed by 二货机器人
parent 670bd4bf5b
commit df8f34309f
2 changed files with 3 additions and 10 deletions

View File

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

View File

@ -613,6 +613,7 @@ describe('Table.sorter', () => {
createTable({ createTable({
pagination: { pagination: {
pageSize: 2, pageSize: 2,
defaultCurrent: 2,
onChange: onPageChange, onChange: onPageChange,
}, },
onChange, onChange,
@ -620,8 +621,8 @@ describe('Table.sorter', () => {
); );
wrapper.find('.ant-table-column-sorters').simulate('click'); wrapper.find('.ant-table-column-sorters').simulate('click');
expect(onChange.mock.calls[0][0].current).toBe(1); expect(onChange.mock.calls[0][0].current).toBe(2);
expect(onPageChange.mock.calls[0][0]).toBe(1); expect(onPageChange).not.toHaveBeenCalled();
}); });
it('should support onHeaderCell in sort column', () => { it('should support onHeaderCell in sort column', () => {