From 12a59a25210d438451a7cc738bfa1e2a6f9519d5 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 13 Oct 2023 03:48:25 -0400 Subject: [PATCH] [8.11] [Security Solution] Fixes ES|QL Tab resetting to KQL Bar (#168716) (#168784) # Backport This will backport the following commits from `main` to `8.11`: - [[Security Solution] Fixes ES|QL Tab resetting to KQL Bar (#168716)](https://github.com/elastic/kibana/pull/168716) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Jatin Kathuria --- .../components/timeline/discover_tab_content/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/discover_tab_content/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/discover_tab_content/index.tsx index 97737a8ebfc3b..b3697421906ef 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/discover_tab_content/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/discover_tab_content/index.tsx @@ -181,6 +181,10 @@ export const DiscoverTabContent: FC = ({ timelineId }) if (!savedObjectId) return; if (!status || status === 'draft') return; const latestState = getCombinedDiscoverSavedSearchState(); + const index = latestState?.searchSource.getField('index'); + /* when a new timeline is loaded, a new discover instance is loaded which first emits + * discover's initial state which is then updated in the saved search. We want to avoid that.*/ + if (!index) return; if (!latestState || combinedDiscoverSavedSearchStateRef.current === latestState) return; if (isEqualWith(latestState, savedSearchById, savedSearchComparator)) return; debouncedUpdateSavedSearch(latestState, timelineId);