Skip to content

Commit 5cfa44e

Browse files
committed
fix: improve pagination stability by updating totalPages reference condition
1 parent f2675be commit 5cfa44e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/components/PaginatedNavigation.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ export const PaginatedNavigation = ({
2323
// Keep stable totalPages to prevent pagination from disappearing during loading
2424
const lastValidTotalPagesRef = useRef<number>(1);
2525

26-
// Only update the ref if we have a valid totalPages (> 0)
27-
if (totalPages > 0) {
26+
// Only update the ref if we have a valid totalPages that's greater than or equal to the current one
27+
// This prevents the pagination from shrinking during loading states
28+
if (totalPages > 0 && totalPages >= lastValidTotalPagesRef.current) {
2829
lastValidTotalPagesRef.current = totalPages;
2930
}
3031

0 commit comments

Comments
 (0)