1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00

fix: limit reset when no pagination bar

This commit is contained in:
kwasniew 2025-09-09 12:34:13 +02:00
parent 2cd8135988
commit 8137de0be7
No known key found for this signature in database
GPG Key ID: 43A7CBC24C119560
2 changed files with 13 additions and 7 deletions

View File

@ -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<PaginationBarProps> = ({
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(

View File

@ -51,6 +51,19 @@ export const usePersistentTableState = <T extends QueryParamConfigMap>(
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];