mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 03:29:39 +08:00
fix: Not merge additional data (#27412)
This commit is contained in:
parent
abb724565d
commit
39333253d9
@ -39,7 +39,7 @@ describe('Table.pagination', () => {
|
|||||||
|
|
||||||
it('not crash when pageSize is undefined', () => {
|
it('not crash when pageSize is undefined', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
mount(createTable({ pagination: { pageSIze: undefined } }));
|
mount(createTable({ pagination: { pageSize: undefined } }));
|
||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -409,4 +409,36 @@ describe('Table.pagination', () => {
|
|||||||
});
|
});
|
||||||
expect(wrapper.find('.ant-pagination')).toHaveLength(2);
|
expect(wrapper.find('.ant-pagination')).toHaveLength(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('showTotal should hide when removed', () => {
|
||||||
|
const Demo = () => {
|
||||||
|
const [p, setP] = React.useState({
|
||||||
|
showTotal: t => `>${t}<`,
|
||||||
|
total: 200,
|
||||||
|
current: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Table
|
||||||
|
data={[]}
|
||||||
|
columns={[]}
|
||||||
|
pagination={p}
|
||||||
|
onChange={pg => {
|
||||||
|
setP({
|
||||||
|
...pg,
|
||||||
|
total: 23,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = mount(<Demo />);
|
||||||
|
expect(wrapper.find('.ant-pagination-total-text').text()).toEqual('>200<');
|
||||||
|
|
||||||
|
// Should hide
|
||||||
|
wrapper.find('.ant-pagination-item-2').simulate('click');
|
||||||
|
expect(wrapper.find('.ant-pagination-total-text')).toHaveLength(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -50,7 +50,10 @@ export default function usePagination(
|
|||||||
const { total: paginationTotal = 0, ...paginationObj } =
|
const { total: paginationTotal = 0, ...paginationObj } =
|
||||||
pagination && typeof pagination === 'object' ? pagination : {};
|
pagination && typeof pagination === 'object' ? pagination : {};
|
||||||
|
|
||||||
const [innerPagination, setInnerPagination] = useState<TablePaginationConfig>(() => {
|
const [innerPagination, setInnerPagination] = useState<{
|
||||||
|
current?: number;
|
||||||
|
pageSize?: number;
|
||||||
|
}>(() => {
|
||||||
return {
|
return {
|
||||||
current: 'defaultCurrent' in paginationObj ? paginationObj.defaultCurrent : 1,
|
current: 'defaultCurrent' in paginationObj ? paginationObj.defaultCurrent : 1,
|
||||||
pageSize:
|
pageSize:
|
||||||
@ -77,7 +80,6 @@ export default function usePagination(
|
|||||||
|
|
||||||
const refreshPagination = (current: number = 1, pageSize?: number) => {
|
const refreshPagination = (current: number = 1, pageSize?: number) => {
|
||||||
setInnerPagination({
|
setInnerPagination({
|
||||||
...mergedPagination,
|
|
||||||
current,
|
current,
|
||||||
pageSize: pageSize || mergedPagination.pageSize,
|
pageSize: pageSize || mergedPagination.pageSize,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user