Skip to content

Commit a04dcd5

Browse files
authored
fix: quick jumper should hide when specify pageSize (#362)
close ant-design/ant-design#32991
1 parent dbddb76 commit a04dcd5

File tree

4 files changed

+48
-23
lines changed

4 files changed

+48
-23
lines changed

docs/examples/jumper.jsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function onChange(current, pageSize) {
1717

1818
const App = () => (
1919
<>
20+
<h3>默认</h3>
2021
<Pagination
2122
selectComponentClass={Select}
2223
showQuickJumper
@@ -27,10 +28,10 @@ const App = () => (
2728
onChange={onChange}
2829
total={450}
2930
/>
30-
<br />
31+
<h3>禁用</h3>
3132
<Pagination
3233
selectComponentClass={Select}
33-
showQuickJumper={{ goButton: true }}
34+
showQuickJumper
3435
showSizeChanger
3536
defaultPageSize={20}
3637
defaultCurrent={5}
@@ -39,6 +40,25 @@ const App = () => (
3940
total={450}
4041
disabled
4142
/>
43+
<h3>单页默认隐藏</h3>
44+
<Pagination
45+
selectComponentClass={Select}
46+
showQuickJumper
47+
showSizeChanger
48+
onShowSizeChange={onShowSizeChange}
49+
onChange={onChange}
50+
total={8}
51+
/>
52+
<br />
53+
<Pagination
54+
selectComponentClass={Select}
55+
showQuickJumper
56+
showSizeChanger
57+
onShowSizeChange={onShowSizeChange}
58+
onChange={onChange}
59+
pageSize={10}
60+
total={8}
61+
/>
4262
</>
4363
);
4464

src/Pagination.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ class Pagination extends React.Component {
185185
};
186186

187187
shouldDisplayQuickJumper = () => {
188-
const { showQuickJumper, pageSize, total } = this.props;
188+
const { showQuickJumper, total } = this.props;
189+
const { pageSize } = this.state;
189190
if (total <= pageSize) {
190191
return false;
191192
}

tests/jumper.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,28 @@ describe('simple quick jumper', () => {
192192
wrapper.find('.rc-pagination-options-quick-jumper-button').exists(),
193193
).toBe(false);
194194
});
195+
196+
it('Quick Jumper should hide when only one page', () => {
197+
wrapper = mount(
198+
<Pagination onChange={onChange} total={5} showQuickJumper />,
199+
);
200+
expect(wrapper.find('.rc-pagination-options-quick-jumper').exists()).toBe(
201+
false,
202+
);
203+
});
204+
205+
// https://github.com/ant-design/ant-design/issues/32991
206+
it('Quick Jumper should hide when only one page when has pageSize', () => {
207+
wrapper = mount(
208+
<Pagination
209+
onChange={onChange}
210+
total={5}
211+
pageSize={10}
212+
showQuickJumper
213+
/>,
214+
);
215+
expect(wrapper.find('.rc-pagination-options-quick-jumper').exists()).toBe(
216+
false,
217+
);
218+
});
195219
});

tsconfig.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)