Skip to content

Commit

Permalink
[Security Solution] Fixes ES|QL Tab resetting to KQL Bar (elastic#168716
Browse files Browse the repository at this point in the history
)

## Summary

Handles elastic#168431

This PR fixes a race condition which was causing Discover ES|QL tab to
revert to it KQL query bar. See demo below:

| Before | After |
|---|---|
| <video
src="https://github.com/elastic/kibana/assets/7485038/24ff8ca9-30ce-4581-94d7-52908a2c81fd"
/>|<video
src="https://github.com/elastic/kibana/assets/7485038/746946ad-bd69-412f-bd38-d3d79b570c68"
/>|
  • Loading branch information
logeekal authored Oct 13, 2023
1 parent 7780965 commit 6fd6966
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export const DiscoverTabContent: FC<DiscoverTabContentProps> = ({ 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);
Expand Down

0 comments on commit 6fd6966

Please sign in to comment.