mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 00:48:25 +00:00
Bugfix/table pageindex sync with total pages (#1263)
* Update table page data when page index is updated * Pass pageIndex from useTable hook as lastActivePageIndex for pagination * Goto last page in table whenever page count is less than current page index
This commit is contained in:
parent
939303f3ad
commit
ef9951b255
2 changed files with 8 additions and 1 deletions
|
|
@ -21,7 +21,10 @@ export const Pagination = function Pagination({
|
|||
setPageCount(lastActivePageIndex);
|
||||
} else if (serverSide || lastActivePageIndex === 0) {
|
||||
setPageIndex(1);
|
||||
} else {
|
||||
gotoPage(lastActivePageIndex + 1);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [serverSide, lastActivePageIndex]);
|
||||
|
||||
function gotoPage(page) {
|
||||
|
|
|
|||
|
|
@ -756,6 +756,10 @@ export function Table({
|
|||
}
|
||||
}, [state.columnResizing.isResizingColumn]);
|
||||
|
||||
useEffect(() => {
|
||||
if (pageCount <= pageIndex) gotoPage(pageCount - 1);
|
||||
}, [pageCount]);
|
||||
|
||||
return (
|
||||
<div
|
||||
data-disabled={parsedDisabledState}
|
||||
|
|
@ -891,7 +895,7 @@ export function Table({
|
|||
<div className="col">
|
||||
{(clientSidePagination || serverSidePagination) && (
|
||||
<Pagination
|
||||
lastActivePageIndex={currentState.components[component.name]?.pageIndex ?? 1}
|
||||
lastActivePageIndex={pageIndex}
|
||||
serverSide={serverSidePagination}
|
||||
autoGotoPage={gotoPage}
|
||||
autoCanNextPage={canNextPage}
|
||||
|
|
|
|||
Loading…
Reference in a new issue