Skip to content

Commit 20d5672

Browse files
committed
Show pagination when count is undefined
1 parent 9a0ce5d commit 20d5672

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

site/src/components/PaginationWidget/PaginationWidget.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ export const PaginationWidget = ({
3434
const currentPage = paginationState.context.page
3535
const numRecordsPerPage = paginationState.context.limit
3636

37-
const numPages = numRecords ? Math.ceil(numRecords / numRecordsPerPage) : 0
37+
const numPages = numRecords ? Math.ceil(numRecords / numRecordsPerPage) : undefined
3838
const firstPageActive = currentPage === 1 && numPages !== 0
3939
const lastPageActive = currentPage === numPages && numPages !== 0
4040

4141
// No need to display any pagination if we know the number of pages is 1 or 0
42-
if (numPages <= 1 || numRecords === 0) {
42+
if (numPages && numPages <= 1 || numRecords === 0) {
4343
return null
4444
}
4545

@@ -54,7 +54,7 @@ export const PaginationWidget = ({
5454
<KeyboardArrowLeft />
5555
<div>{prevLabel}</div>
5656
</Button>
57-
<Maybe condition={numPages > 0}>
57+
<Maybe condition={numPages !== undefined}>
5858
<ChooseOne>
5959
<Cond condition={isMobile}>
6060
<PageButton
@@ -64,7 +64,7 @@ export const PaginationWidget = ({
6464
/>
6565
</Cond>
6666
<Cond>
67-
{buildPagedList(numPages, currentPage).map((page) =>
67+
{numPages && buildPagedList(numPages, currentPage).map((page) =>
6868
typeof page !== "number" ? (
6969
<PageButton
7070
key={`Page${page}`}

0 commit comments

Comments
 (0)