From 60134bfe7acce8281a26e4d037499f5d47b3ff0d Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Thu, 30 Mar 2023 16:13:08 +0200 Subject: [PATCH] fix(ui) - url search page reset --- .../SessionSearchQueryParamHandler.tsx | 2 +- frontend/app/duck/search.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/app/components/shared/SessionSearchQueryParamHandler/SessionSearchQueryParamHandler.tsx b/frontend/app/components/shared/SessionSearchQueryParamHandler/SessionSearchQueryParamHandler.tsx index 5bd5d739d..e38729b2a 100644 --- a/frontend/app/components/shared/SessionSearchQueryParamHandler/SessionSearchQueryParamHandler.tsx +++ b/frontend/app/components/shared/SessionSearchQueryParamHandler/SessionSearchQueryParamHandler.tsx @@ -17,7 +17,7 @@ const SessionSearchQueryParamHandler = (props: Props) => { const applyFilterFromQuery = () => { const filter = getFiltersFromQuery(history.location.search, appliedFilter); - props.updateFilter(filter, true); + props.updateFilter(filter, true, false); }; const generateUrlQuery = () => { diff --git a/frontend/app/duck/search.js b/frontend/app/duck/search.js index 31f028bc3..1f68d1994 100644 --- a/frontend/app/duck/search.js +++ b/frontend/app/duck/search.js @@ -71,8 +71,11 @@ function reducer(state = initialState, action = {}) { case EDIT: return state.mergeIn(['instance'], action.instance).set('currentPage', 1); case APPLY: - - return action.fromUrl ? state.set('instance', Filter(action.filter)) : state.mergeIn(['instance'], action.filter).set('currentPage', 1); + state.mergeIn(['instance'], action.filter).set('currentPage', 1); + if (action.resetPage) { + state.set('currentPage', 1) + } + return state case success(FETCH): return state.set('instance', action.data); case success(FETCH_LIST): @@ -243,10 +246,11 @@ export const applyFilter = reduceThenFetchResource((filter, force = false) => ({ force, })); -export const updateFilter = (filter, force = false) => ({ +export const updateFilter = (filter, force = false, resetPage = true) => ({ type: APPLY, filter, force, + resetPage, }); export const updateCurrentPage = reduceThenFetchResource((page) => ({