From 41f00e7f5fd0454f04dfea4c9d98fb4b2a734893 Mon Sep 17 00:00:00 2001 From: "Qingyang(Abby) Hu" Date: Thu, 12 Sep 2024 18:35:25 -0700 Subject: [PATCH] Sync query and filter when refreshing discover page (#8179) Signed-off-by: abbyhu2000 --- .../public/application/view_components/utils/use_search.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/discover/public/application/view_components/utils/use_search.ts b/src/plugins/discover/public/application/view_components/utils/use_search.ts index d0f4fa8d50b5..91b896f143f1 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_search.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_search.ts @@ -324,6 +324,11 @@ export const useSearch = (services: DiscoverViewServices) => { const savedSearchInstance = await getSavedSearchById(savedSearchId); setSavedSearch(savedSearchInstance); + // if saved search does not exist, do not atempt to sync filters and query from savedObject + if (!savedSearch) { + return; + } + // sync initial app filters from savedObject to filterManager const filters = cloneDeep(savedSearchInstance.searchSource.getOwnField('filter')); const query =