Skip to content

Commit

Permalink
fix: next button is not enabled with pageUnknown prop (#17407)
Browse files Browse the repository at this point in the history
Co-authored-by: Gururaj J <89023023+Gururajj77@users.noreply.github.com>
  • Loading branch information
preetibansalui and Gururajj77 authored Sep 13, 2024
1 parent 885a114 commit 72fb7c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/react/src/components/Pagination/Pagination-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ describe('Pagination', () => {
).not.toBeInTheDocument();
});

it('Next button should be enabled if totalItems undefined and pagesUnknown is true', () => {
render(<Pagination pagesUnknown={true} pageSizes={[10]} />);
expect(screen.getByLabelText('Next page')).not.toBeDisabled();
});

it('should handle zero total items', () => {
render(
<Pagination
Expand All @@ -231,7 +236,7 @@ describe('Pagination', () => {
page={1}
/>
);

expect(screen.getByLabelText('Next page')).toBeDisabled();
expect(screen.getByText('0–0 of 0 items')).toBeInTheDocument();
});
});
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ const Pagination = React.forwardRef(function Pagination(
[`${prefix}--pagination__button--backward`]: true,
[`${prefix}--pagination__button--no-index`]: backButtonDisabled,
});
const forwardButtonDisabled = disabled || page === totalPages;
const forwardButtonDisabled =
disabled || (page === totalPages && !pagesUnknown);
const forwardButtonClasses = cx({
[`${prefix}--pagination__button`]: true,
[`${prefix}--pagination__button--forward`]: true,
Expand Down

0 comments on commit 72fb7c0

Please sign in to comment.