fix: Table onShowSizeChange trigger twice (#27417)

close #26100
close #27392
This commit is contained in:
偏右 2020-10-28 12:56:05 +08:00 committed by GitHub
parent a7ce8039b9
commit cc8ec58ab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -285,7 +285,7 @@ describe('Table.pagination', () => {
expect(wrapper.find('.ant-table-tbody tr.ant-table-row')).toHaveLength(data.length);
});
it('select by checkbox to trigger stopPropagation', () => {
it('onShowSizeChange should trigger once', () => {
jest.useFakeTimers();
const onShowSizeChange = jest.fn();
const onChange = jest.fn();
@ -304,7 +304,8 @@ describe('Table.pagination', () => {
const dropdownWrapper = mount(wrapper.find('Trigger').instance().getComponent());
expect(wrapper.find('.ant-select-item-option').length).toBe(4);
dropdownWrapper.find('.ant-select-item-option').at(3).simulate('click');
expect(onShowSizeChange).toHaveBeenCalled();
expect(onShowSizeChange).toHaveBeenCalledTimes(1);
expect(onShowSizeChange).toHaveBeenLastCalledWith(1, 100);
expect(onChange).toHaveBeenCalled();
jest.useRealTimers();
});

View File

@ -89,7 +89,6 @@ export default function usePagination(
const paginationPageSize = mergedPagination?.pageSize;
if (pageSize && pageSize !== paginationPageSize) {
current = 1;
if (pagination && pagination.onShowSizeChange) pagination.onShowSizeChange(current, pageSize);
}
if (pagination && pagination.onChange) pagination.onChange(current, pageSize);