Skip to content

Commit

Permalink
fix pagination (#303)
Browse files Browse the repository at this point in the history
#243

Fixes pagination by using the correct count when filters are applied
  • Loading branch information
codemonkey800 authored Dec 22, 2023
1 parent fa0029b commit 3701925
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions frontend/packages/data-portal/app/components/TablePageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,22 @@ export function TablePageLayout({
<div className="px-sds-xl">
{filteredCount === 0 && noResults}

<div className="w-full flex justify-center">
<Pagination
currentPage={page}
pageSize={MAX_PER_PAGE}
totalCount={totalCount}
onNextPage={() => setPage(page + 1)}
onPreviousPage={() => setPage(page - 1)}
onPageChange={(nextPage) => setPage(nextPage)}
/>
</div>
{filteredCount > MAX_PER_PAGE && (
<div className="w-full flex justify-center mt-sds-xxl">
<Pagination
currentPage={page}
pageSize={MAX_PER_PAGE}
totalCount={
totalCount === filteredCount
? totalCount
: filteredCount
}
onNextPage={() => setPage(page + 1)}
onPreviousPage={() => setPage(page - 1)}
onPageChange={(nextPage) => setPage(nextPage)}
/>
</div>
)}
</div>
</div>
</div>
Expand Down

0 comments on commit 3701925

Please sign in to comment.