summaryrefslogtreecommitdiff
path: root/src/hooks/use-pagination.tsx
diff options
context:
space:
mode:
authorBertrand Yuan <noreply@bertyuan.com>2026-03-26 00:02:16 +0800
committerBertrand Yuan <noreply@bertyuan.com>2026-03-26 00:02:16 +0800
commit8a6a6712e7554f110b5ef951f270d88fd010e040 (patch)
tree12cb86b1ede55e15600ef7f139ef7ec91b9fa8a1 /src/hooks/use-pagination.tsx
parentf7a02fe0e112cf108fc5f22872f1efc077e99fe8 (diff)
add more tests
Diffstat (limited to 'src/hooks/use-pagination.tsx')
-rw-r--r--src/hooks/use-pagination.tsx5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/hooks/use-pagination.tsx b/src/hooks/use-pagination.tsx
index d009cd4..40ed979 100644
--- a/src/hooks/use-pagination.tsx
+++ b/src/hooks/use-pagination.tsx
@@ -15,8 +15,11 @@ export function usePagination({
totalPages,
paginationItemsToDisplay,
}: UsePaginationProps): UsePaginationReturn {
- const showLeftEllipsis = currentPage - 1 > paginationItemsToDisplay / 2;
+ const shouldTruncate = totalPages > paginationItemsToDisplay;
+ const showLeftEllipsis =
+ shouldTruncate && currentPage - 1 > paginationItemsToDisplay / 2;
const showRightEllipsis =
+ shouldTruncate &&
totalPages - currentPage + 1 > paginationItemsToDisplay / 2;
function calculatePaginationRange(): number[] {