1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00

feat: pagination reset on feature list (#5644)

This commit is contained in:
Mateusz Kwasniewski 2023-12-14 13:44:27 +01:00 committed by GitHub
parent a595c0fbcc
commit 772682176e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -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',
);
});

View File

@ -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 || ''}>