mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
allow nullable pagination input
This commit is contained in:
1 parent
f97e262bc0
commit
fb991dd49e
1 file changed
+7
-3
@@ -24,7 +24,7 @@ type PaginationProps = {}
|
||||
const Pagination: FC<PaginationProps> = () => {
|
||||
const state = useTrackedState()
|
||||
const dispatch = useDispatch()
|
||||
const [page, setPage] = useState(state.page)
|
||||
const [page, setPage] = useState<number | null>(state.page)
|
||||
const maxPages = Math.ceil(state.totalRows / state.rowsPerPage)
|
||||
const totalPages = state.totalRows > 0 ? maxPages : 1
|
||||
|
||||
@@ -90,8 +90,10 @@ const Pagination: FC<PaginationProps> = () => {
|
||||
function onPageChange(event: React.ChangeEvent<HTMLInputElement>) {
|
||||
const value = event.target.value
|
||||
const pageNum = Number(value) > maxPages ? maxPages : Number(value)
|
||||
setPage(pageNum)
|
||||
updatePageDebounced(pageNum, dispatch)
|
||||
setPage(pageNum || null)
|
||||
if (pageNum) {
|
||||
updatePageDebounced(pageNum, dispatch)
|
||||
}
|
||||
}
|
||||
|
||||
function onRowsPerPageChange(value: string | number) {
|
||||
@@ -114,6 +116,8 @@ const Pagination: FC<PaginationProps> = () => {
|
||||
<p className="text-scale-1100 text-sm">Page</p>
|
||||
<div className="sb-grid-pagination-input-container">
|
||||
<InputNumber
|
||||
// [Fran] we'll have to upgrade the UI component types to accept the null value when users delete the input content
|
||||
// @ts-ignore
|
||||
value={page}
|
||||
onChange={onPageChange}
|
||||
size="tiny"
|
||||
|
||||
Reference in new issue
Block a user