diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/esql_tab_content/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/esql_tab_content/index.tsx index 97737a8ebfc3b..b3697421906ef 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/esql_tab_content/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/esql_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);