mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
fix: Table topPaginationNode display logic should same with bottomPaginationNode (#26143)
* fix: Tree bottomPaginationNode display logic should same with bottomPaginationNode * update: test
This commit is contained in:
parent
77cbf724cf
commit
c47bfb0c91
@ -420,7 +420,7 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
|
||||
|
||||
let topPaginationNode: React.ReactNode;
|
||||
let bottomPaginationNode: React.ReactNode;
|
||||
if (pagination !== false) {
|
||||
if (pagination !== false && mergedPagination?.total) {
|
||||
let paginationSize: TablePaginationConfig['size'];
|
||||
if (mergedPagination.size) {
|
||||
paginationSize = mergedPagination.size;
|
||||
@ -495,7 +495,7 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
|
||||
internalRefs={internalRefs as any}
|
||||
transformColumns={transformColumns}
|
||||
/>
|
||||
{mergedData && mergedData.length > 0 && bottomPaginationNode}
|
||||
{bottomPaginationNode}
|
||||
</Spin>
|
||||
</div>
|
||||
);
|
||||
|
@ -378,39 +378,24 @@ describe('Table.pagination', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should render pagination after last item on last page being removed with async mode', () => {
|
||||
const lastPageNum = data.length;
|
||||
it('should render pagination after last item on last page being removed', () => {
|
||||
const total = data.length;
|
||||
const paginationProp = {
|
||||
pageSize: 1,
|
||||
total,
|
||||
current: total,
|
||||
position: ['topLeft', 'bottomLeft'],
|
||||
};
|
||||
const wrapper = mount(
|
||||
createTable({ pagination: { pageSize: 1, total: data.length, current: lastPageNum } }),
|
||||
createTable({
|
||||
pagination: paginationProp,
|
||||
}),
|
||||
);
|
||||
|
||||
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);
|
||||
wrapper.setProps({
|
||||
dataSource: data.slice(total - 1),
|
||||
pagination: { ...paginationProp, total: total - 1 },
|
||||
});
|
||||
expect(wrapper.find('.ant-pagination')).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user