diff --git a/frontend/src/components/pagination.tsx b/frontend/src/components/pagination.tsx index 466bb0f..9283627 100644 --- a/frontend/src/components/pagination.tsx +++ b/frontend/src/components/pagination.tsx @@ -11,6 +11,10 @@ export default function Pagination({ lastPage }: Props) { const [searchParams] = useSearchParams(); const page = Number(searchParams.get("page") ?? 1); + const scrollToTop = useCallback(() => { + window.scrollTo({ top: 0 }); + }, []); + const createPageUrl = useCallback( (pageNumber: number) => { const params = new URLSearchParams(searchParams); @@ -37,6 +41,7 @@ export default function Pagination({ lastPage }: Props) { {/* Go to first page */} = lastPage ? "#" : createPageUrl(page + 1)} + onClick={page >= lastPage ? undefined : scrollToTop} aria-label="Go to Next Page" aria-disabled={page >= lastPage} tabIndex={page >= lastPage ? -1 : undefined} @@ -85,6 +93,7 @@ export default function Pagination({ lastPage }: Props) { {/* Go to last page */} = lastPage ? "#" : createPageUrl(lastPage)} + onClick={page >= lastPage ? undefined : scrollToTop} aria-label="Go to Last Page" aria-disabled={page >= lastPage} tabIndex={page >= lastPage ? -1 : undefined}