diff --git a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListTable.test.tsx b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListTable.test.tsx index ee54ecad2b..4643326dac 100644 --- a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListTable.test.tsx +++ b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListTable.test.tsx @@ -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', + ); }); diff --git a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListTable.tsx b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListTable.tsx index c5d4549475..9a1c905d77 100644 --- a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListTable.tsx +++ b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListTable.tsx @@ -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 = () => { - 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 = () => { } >