Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {

if (simple) {
nextDisabled = !hasNext;
nextTabIndex = hasPrev ? 0 : null;
nextTabIndex = nextDisabled ? null : 0;
} else {
nextDisabled = !hasNext || !allPages;
nextTabIndex = nextDisabled ? null : 0;
Expand Down
9 changes: 8 additions & 1 deletion tests/__snapshots__/demo.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Example align 1`] = `
<div>
Expand Down Expand Up @@ -2704,6 +2704,7 @@ exports[`Example jumperWithGoButton 1`] = `
aria-label="下一页"
class="rc-pagination-next"
role="button"
tabindex="0"
>
<button
aria-hidden="true"
Expand Down Expand Up @@ -4349,6 +4350,7 @@ exports[`Example simple 1`] = `
aria-label="下一页"
class="rc-pagination-next"
role="button"
tabindex="0"
>
<button
aria-hidden="true"
Expand Down Expand Up @@ -4395,6 +4397,7 @@ exports[`Example simple 1`] = `
aria-label="下一页"
class="rc-pagination-next"
role="button"
tabindex="0"
>
<button
aria-hidden="true"
Expand Down Expand Up @@ -4446,6 +4449,7 @@ exports[`Example simple 1`] = `
aria-label="下一页"
class="rc-pagination-next"
role="button"
tabindex="0"
>
<button
aria-hidden="true"
Expand Down Expand Up @@ -4502,6 +4506,7 @@ exports[`Example simple 1`] = `
aria-label="下一页"
class="rc-pagination-next"
role="button"
tabindex="0"
>
<button
aria-hidden="true"
Expand Down Expand Up @@ -4553,6 +4558,7 @@ exports[`Example simple 1`] = `
aria-label="下一页"
class="rc-pagination-next"
role="button"
tabindex="0"
>
<button
aria-hidden="true"
Expand Down Expand Up @@ -4636,6 +4642,7 @@ exports[`Example simple 1`] = `
aria-label="下一页"
class="rc-pagination-next"
role="button"
tabindex="0"
>
<button
aria-hidden="true"
Expand Down
15 changes: 15 additions & 0 deletions tests/simple.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ describe('simple Pagination', () => {
expect(onChange).toHaveBeenLastCalledWith(2, 10);
});

it('should set correct tabIndex for prev and next buttons in simple mode', () => {
const { container, rerender } = render(
<Pagination simple defaultCurrent={1} total={25} />,
);
const prev = container.querySelector('.rc-pagination-prev');
const next = container.querySelector('.rc-pagination-next');

expect(prev).not.toHaveAttribute('tabindex');
expect(next).toHaveAttribute('tabindex', '0');

rerender(<Pagination simple current={3} total={25} />);
expect(prev).toHaveAttribute('tabindex', '0');
expect(next).not.toHaveAttribute('tabindex');
});

it('should return to 1 when blur goto input in uncontrol mode', () => {
const { container } = render(
<Pagination simple defaultCurrent={1} total={25} />,
Expand Down