Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions docs/examples/jumper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function onChange(current, pageSize) {

const App = () => (
<>
<h3>默认</h3>
<Pagination
selectComponentClass={Select}
showQuickJumper
Expand All @@ -27,10 +28,10 @@ const App = () => (
onChange={onChange}
total={450}
/>
<br />
<h3>禁用</h3>
<Pagination
selectComponentClass={Select}
showQuickJumper={{ goButton: true }}
showQuickJumper
showSizeChanger
defaultPageSize={20}
defaultCurrent={5}
Expand All @@ -39,6 +40,25 @@ const App = () => (
total={450}
disabled
/>
<h3>单页默认隐藏</h3>
<Pagination
selectComponentClass={Select}
showQuickJumper
showSizeChanger
onShowSizeChange={onShowSizeChange}
onChange={onChange}
total={8}
/>
<br />
<Pagination
selectComponentClass={Select}
showQuickJumper
showSizeChanger
onShowSizeChange={onShowSizeChange}
onChange={onChange}
pageSize={10}
total={8}
/>
</>
);

Expand Down
3 changes: 2 additions & 1 deletion src/Pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class Pagination extends React.Component {
};

shouldDisplayQuickJumper = () => {
const { showQuickJumper, pageSize, total } = this.props;
const { showQuickJumper, total } = this.props;
const { pageSize } = this.state;
if (total <= pageSize) {
return false;
}
Expand Down
24 changes: 24 additions & 0 deletions tests/jumper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,28 @@ describe('simple quick jumper', () => {
wrapper.find('.rc-pagination-options-quick-jumper-button').exists(),
).toBe(false);
});

it('Quick Jumper should hide when only one page', () => {
wrapper = mount(
<Pagination onChange={onChange} total={5} showQuickJumper />,
);
expect(wrapper.find('.rc-pagination-options-quick-jumper').exists()).toBe(
false,
);
});

// https://github.com/ant-design/ant-design/issues/32991
it('Quick Jumper should hide when only one page when has pageSize', () => {
wrapper = mount(
<Pagination
onChange={onChange}
total={5}
pageSize={10}
showQuickJumper
/>,
);
expect(wrapper.find('.rc-pagination-options-quick-jumper').exists()).toBe(
false,
);
});
});
20 changes: 0 additions & 20 deletions tsconfig.json

This file was deleted.