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:
parent
2cd8135988
commit
8137de0be7
@ -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(
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user