diff --git a/frontend/src/component/common/Table/PaginationBar/PaginationBar.tsx b/frontend/src/component/common/Table/PaginationBar/PaginationBar.tsx index 7e265ea05e..9660ddde2e 100644 --- a/frontend/src/component/common/Table/PaginationBar/PaginationBar.tsx +++ b/frontend/src/component/common/Table/PaginationBar/PaginationBar.tsx @@ -1,5 +1,4 @@ import type React from 'react'; -import { useEffect } from 'react'; import { Box, Typography, Button, styled } from '@mui/material'; import { ConditionallyRender } from '../../ConditionallyRender/ConditionallyRender.tsx'; import { ReactComponent as ArrowRight } from 'assets/icons/arrowRight.svg'; @@ -61,12 +60,6 @@ export const PaginationBar: React.FC = ({ fetchNextPage, setPageLimit, }) => { - useEffect(() => { - if (![25, 50, 75, 100].includes(pageSize)) { - setPageLimit(25); - } - }, [pageSize]); - const itemRange = totalItems !== undefined && pageSize && totalItems > 1 ? `${pageIndex * pageSize + 1}-${Math.min( diff --git a/frontend/src/hooks/usePersistentTableState.ts b/frontend/src/hooks/usePersistentTableState.ts index 6087033bc8..5d13618372 100644 --- a/frontend/src/hooks/usePersistentTableState.ts +++ b/frontend/src/hooks/usePersistentTableState.ts @@ -51,6 +51,19 @@ export const usePersistentTableState = ( return reorderObject(tableState, [...searchParams.keys()]); }, [searchParams, tableState, reorderObject]); + useEffect(() => { + if ( + tableState.limit && + ![25, 50, 75, 100].includes(tableState.limit as number) + ) { + setTableStateInternal((prevState) => ({ + ...prevState, + limit: 25, + offset: 0, // Reset offset when changing limit + })); + } + }, [tableState.limit, setTableStateInternal]); + type SetTableStateInternalParam = Parameters< typeof setTableStateInternal >[0];