Browse Source

fix: #26126 use mergedData instead of pageData to decide if render bottom pagination (#26133)

Co-authored-by: Zhongxian Liang <zhongxian.liang@shopee.com>
pull/26153/head
QoVoQ 4 years ago
committed by GitHub
parent
commit
f65013994f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      components/table/Table.tsx
  2. 38
      components/table/__tests__/Table.pagination.test.js

2
components/table/Table.tsx

@ -495,7 +495,7 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
internalRefs={internalRefs as any}
transformColumns={transformColumns}
/>
{pageData && pageData.length > 0 && bottomPaginationNode}
{mergedData && mergedData.length > 0 && bottomPaginationNode}
</Spin>
</div>
);

38
components/table/__tests__/Table.pagination.test.js

@ -349,7 +349,7 @@ describe('Table.pagination', () => {
const dropdownWrapper = mount(wrapper.find('Trigger').instance().getComponent());
dropdownWrapper.find('.ant-select-item-option').at(2).simulate('click');
expect(onChange).toBeCalledTimes(1)
expect(onChange).toBeCalledTimes(1);
});
it('dynamic warning', () => {
@ -377,4 +377,40 @@ describe('Table.pagination', () => {
'Warning: [antd: Table] `dataSource` length is less than `pagination.total` but large than `pagination.pageSize`. Please make sure your config correct data with async mode.',
);
});
it('should render pagination after last item on last page being removed with async mode', () => {
const lastPageNum = data.length;
const wrapper = mount(
createTable({ pagination: { pageSize: 1, total: data.length, current: lastPageNum } }),
);
const newCol = [
{
title: 'Name',
dataIndex: 'name',
},
{
title: 'Action',
dataIndex: 'name',
render(_, record) {
const deleteRow = () => {
const newData = data.filter(d => d.key !== record.key);
wrapper.setProps({
dataSource: newData,
pagination: { pageSize: 1, total: newData.length, current: lastPageNum },
});
};
return (
<span className="btn-delete" onClick={deleteRow}>
Delete
</span>
);
},
},
];
wrapper.setProps({ columns: newCol });
wrapper.find('.btn-delete').simulate('click');
expect(wrapper.find('.ant-pagination')).toHaveLength(1);
});
});

Loading…
Cancel
Save