mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 13:09:40 +08:00
fix: Table onShowSizeChange trigger twice (#27417)
close #26100 close #27392
This commit is contained in:
parent
a7ce8039b9
commit
cc8ec58ab1
@ -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();
|
||||
});
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user