pagination error fixed
This commit is contained in:
parent
569fdc5125
commit
cd4de05a68
@ -14,7 +14,6 @@ export interface PaginationProps {
|
||||
/** Pager: "Showing a–b of N" + Prev/Next. Renders nothing when the set fits on
|
||||
* one page. Shared by the record-view tables. */
|
||||
export function Pagination({ page, pageSize, total, onPage, onPageSizeChange }: PaginationProps) {
|
||||
if (total <= 0) return null;
|
||||
const totalPages = Math.max(1, Math.ceil(total / pageSize));
|
||||
const safePage = Math.min(Math.max(page, 1), totalPages);
|
||||
const start = (safePage - 1) * pageSize;
|
||||
@ -25,6 +24,8 @@ export function Pagination({ page, pageSize, total, onPage, onPageSizeChange }:
|
||||
setJumpPage(safePage.toString());
|
||||
}, [safePage]);
|
||||
|
||||
if (total <= 0) return null;
|
||||
|
||||
const handlePageChange = (newPage: number) => {
|
||||
onPage(newPage);
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user