Skip to content

Commit ba13760

Browse files
authored
fix: quick jump render logic (#553)
* test: add unit test case * fix: quick jump render logic ref: ant-design/ant-design#46671 * test: fix demo test error * chore: update demo * chore: update snap * test: add unit test case * fix: simple quick jumper custom goButton bug
1 parent 455c92a commit ba13760

File tree

6 files changed

+3598
-1036
lines changed

6 files changed

+3598
-1036
lines changed

docs/examples/simple.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ export default () => {
3232
showSizeChanger
3333
selectComponentClass={Select}
3434
/>
35+
<hr />
36+
<a href="https://github.com/ant-design/ant-design/issues/46671">
37+
Antd #46671
38+
</a>
39+
<Pagination
40+
simple
41+
defaultCurrent={1}
42+
total={50}
43+
showSizeChanger
44+
showQuickJumper
45+
selectComponentClass={Select}
46+
/>
3547
</>
3648
);
3749
};

src/Pagination.tsx

+22-17
Original file line numberDiff line numberDiff line change
@@ -348,27 +348,32 @@ const Pagination: React.FC<PaginationProps> = (props) => {
348348
let simplePager: React.ReactNode = null;
349349

350350
if (simple) {
351-
if (typeof goButton === 'boolean') {
351+
// ====== Simple quick jump ======
352+
if (goButton) {
353+
if (typeof goButton === 'boolean') {
354+
gotoButton = (
355+
<button type="button" onClick={handleGoTO} onKeyUp={handleGoTO}>
356+
{locale.jump_to_confirm}
357+
</button>
358+
);
359+
} else {
360+
gotoButton = (
361+
<span onClick={handleGoTO} onKeyUp={handleGoTO}>
362+
{goButton}
363+
</span>
364+
);
365+
}
366+
352367
gotoButton = (
353-
<button type="button" onClick={handleGoTO} onKeyUp={handleGoTO}>
354-
{locale.jump_to_confirm}
355-
</button>
368+
<li
369+
title={showTitle ? `${locale.jump_to}${current}/${allPages}` : null}
370+
className={`${prefixCls}-simple-pager`}
371+
>
372+
{gotoButton}
373+
</li>
356374
);
357-
} else {
358-
<span onClick={handleGoTO} onKeyUp={handleGoTO}>
359-
{goButton}
360-
</span>;
361375
}
362376

363-
gotoButton = (
364-
<li
365-
title={showTitle ? `${locale.jump_to}${current}/${allPages}` : null}
366-
className={`${prefixCls}-simple-pager`}
367-
>
368-
{gotoButton}
369-
</li>
370-
);
371-
372377
simplePager = (
373378
<li
374379
title={showTitle ? `${current}/${allPages}` : null}

0 commit comments

Comments
 (0)