Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #26126 use mergedData instead of pageData to decide whether to render bottom pagination or not #26133

Merged
merged 1 commit into from Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/table/Table.tsx
Expand Up @@ -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>
);
Expand Down
38 changes: 37 additions & 1 deletion components/table/__tests__/Table.pagination.test.js
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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);
});
});