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 type React from 'react';
|
||||||
import { useEffect } from 'react';
|
|
||||||
import { Box, Typography, Button, styled } from '@mui/material';
|
import { Box, Typography, Button, styled } from '@mui/material';
|
||||||
import { ConditionallyRender } from '../../ConditionallyRender/ConditionallyRender.tsx';
|
import { ConditionallyRender } from '../../ConditionallyRender/ConditionallyRender.tsx';
|
||||||
import { ReactComponent as ArrowRight } from 'assets/icons/arrowRight.svg';
|
import { ReactComponent as ArrowRight } from 'assets/icons/arrowRight.svg';
|
||||||
@ -61,12 +60,6 @@ export const PaginationBar: React.FC<PaginationBarProps> = ({
|
|||||||
fetchNextPage,
|
fetchNextPage,
|
||||||
setPageLimit,
|
setPageLimit,
|
||||||
}) => {
|
}) => {
|
||||||
useEffect(() => {
|
|
||||||
if (![25, 50, 75, 100].includes(pageSize)) {
|
|
||||||
setPageLimit(25);
|
|
||||||
}
|
|
||||||
}, [pageSize]);
|
|
||||||
|
|
||||||
const itemRange =
|
const itemRange =
|
||||||
totalItems !== undefined && pageSize && totalItems > 1
|
totalItems !== undefined && pageSize && totalItems > 1
|
||||||
? `${pageIndex * pageSize + 1}-${Math.min(
|
? `${pageIndex * pageSize + 1}-${Math.min(
|
||||||
|
@ -51,6 +51,19 @@ export const usePersistentTableState = <T extends QueryParamConfigMap>(
|
|||||||
return reorderObject(tableState, [...searchParams.keys()]);
|
return reorderObject(tableState, [...searchParams.keys()]);
|
||||||
}, [searchParams, tableState, reorderObject]);
|
}, [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<
|
type SetTableStateInternalParam = Parameters<
|
||||||
typeof setTableStateInternal
|
typeof setTableStateInternal
|
||||||
>[0];
|
>[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user