diff --git a/ui/src/components/Pager.tsx b/ui/src/components/Pager.tsx index a82181b..cb37343 100644 --- a/ui/src/components/Pager.tsx +++ b/ui/src/components/Pager.tsx @@ -1,26 +1,39 @@ +import { cn } from '../lib/cn' import { Button } from './ui' /** Offset pager: "showing X–Y of N" + Prev/Next, bounded to the available pages. Shared by the - * documents listing and the ingestion queue. Renders nothing when there is nothing to page. */ + * documents listing and the ingestion queue. Renders nothing when there is nothing to page — + * which is also what keeps a `sticky` pager from leaving an empty bar on an empty listing. */ export function Pager({ page, pageSize, total, onPage, loading, + sticky = false, }: { page: number pageSize: number total: number onPage: (p: number) => void loading: boolean + /** Pin to the bottom of the scroll area, so paging a long listing never means scrolling to the + * end of it first. Assumes the page gutter both callers share (see the class note below). */ + sticky?: boolean }) { if (total === 0) return null const start = page * pageSize + 1 const end = Math.min((page + 1) * pageSize, total) const lastPage = Math.max(0, Math.ceil(total / pageSize) - 1) return ( -