mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: pagination reset on feature list (#5644)
This commit is contained in:
parent
a595c0fbcc
commit
772682176e
@ -136,5 +136,7 @@ test('Filter table by project', async () => {
|
||||
await screen.findByText(
|
||||
'No feature toggles available. Get started by adding a new feature toggle.',
|
||||
);
|
||||
expect(window.location.href).toContain('?columns=&project=IS%3Aproject-b');
|
||||
expect(window.location.href).toContain(
|
||||
'?offset=0&columns=&project=IS%3Aproject-b',
|
||||
);
|
||||
});
|
||||
|
@ -92,6 +92,9 @@ export const FeatureToggleListTable: VFC = () => {
|
||||
'features-list-table',
|
||||
stateConfig,
|
||||
);
|
||||
// offset needs to be first so we can override it
|
||||
const setTableStateWithOffsetReset: typeof setTableState = (data) =>
|
||||
setTableState({ offset: 0, ...data });
|
||||
|
||||
const filterState = {
|
||||
project: tableState.project,
|
||||
@ -138,7 +141,7 @@ export const FeatureToggleListTable: VFC = () => {
|
||||
<FavoriteIconHeader
|
||||
isActive={tableState.favoritesFirst}
|
||||
onClick={() =>
|
||||
setTableState({
|
||||
setTableStateWithOffsetReset({
|
||||
favoritesFirst: !tableState.favoritesFirst,
|
||||
})
|
||||
}
|
||||
@ -227,7 +230,7 @@ export const FeatureToggleListTable: VFC = () => {
|
||||
);
|
||||
|
||||
const table = useReactTable(
|
||||
withTableState(tableState, setTableState, {
|
||||
withTableState(tableState, setTableStateWithOffsetReset, {
|
||||
columns,
|
||||
data,
|
||||
}),
|
||||
@ -252,7 +255,8 @@ export const FeatureToggleListTable: VFC = () => {
|
||||
}
|
||||
}, [isSmallScreen, isMediumScreen]);
|
||||
|
||||
const setSearchValue = (query = '') => setTableState({ query });
|
||||
const setSearchValue = (query = '') =>
|
||||
setTableStateWithOffsetReset({ query });
|
||||
|
||||
const rows = table.getRowModel().rows;
|
||||
|
||||
@ -336,7 +340,7 @@ export const FeatureToggleListTable: VFC = () => {
|
||||
}
|
||||
>
|
||||
<FeatureToggleFilters
|
||||
onChange={setTableState}
|
||||
onChange={setTableStateWithOffsetReset}
|
||||
state={filterState}
|
||||
/>
|
||||
<SearchHighlightProvider value={tableState.query || ''}>
|
||||
|
Loading…
Reference in New Issue
Block a user