Skip to content

Commit

Permalink
fix: pagination nav adjacent double ellipses
Browse files Browse the repository at this point in the history
  • Loading branch information
riddhybansal committed Oct 17, 2024
1 parent 98b7c28 commit 4345adb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,11 @@ describe('PaginationNav', () => {

expect(screen.getByText('4')).toHaveAttribute('aria-current', 'page');
});

it('should not hide page 1 when active page is 0', () => {
render(<PaginationNav totalItems={4} page={0} />);

expect(screen.getByText('1')).toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ const PaginationNav = React.forwardRef<HTMLElement, PaginationNavProps>(
function pageWouldBeHidden(page: number) {
const startOffset = itemsDisplayedOnPage <= 4 && page > 1 ? 0 : 1;

const wouldBeHiddenInFront = page >= startOffset && page <= cuts.front;
const wouldBeHiddenInFront =
(page >= startOffset && page <= cuts.front) || page === 0;
const wouldBeHiddenInBack =
page >= totalItems - cuts.back - 1 && page <= totalItems - 2;

Expand Down

0 comments on commit 4345adb

Please sign in to comment.