Skip to content

Commit

Permalink
[ML] Fix Index data visualizer not removing query string with loaded …
Browse files Browse the repository at this point in the history
…saved search (#94245)

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
qn895 and kibanamachine authored Mar 11, 2021
1 parent 521c336 commit fa3b2f0
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ export const Page: FC = () => {
ML_PAGES.DATA_VISUALIZER_INDEX_VIEWER,
restorableDefaults
);
const [currentSavedSearch, setCurrentSavedSearch] = useState(mlContext.currentSavedSearch);

const { combinedQuery, currentIndexPattern, currentSavedSearch, kibanaConfig } = mlContext;
const { combinedQuery, currentIndexPattern, kibanaConfig } = mlContext;
const timefilter = useTimefilter({
timeRangeSelector: currentIndexPattern.timeFieldName !== undefined,
autoRefreshSelector: true,
Expand Down Expand Up @@ -193,6 +194,12 @@ export const Page: FC = () => {
searchString: Query['query'];
queryLanguage: SearchQueryLanguage;
}) => {
// When the user loads saved search and then clear or modify the query
// we should remove the saved search and replace it with the index pattern id
if (currentSavedSearch !== null) {
setCurrentSavedSearch(null);
}

setDataVisualizerListState({
...dataVisualizerListState,
searchQuery: searchParams.searchQuery,
Expand Down

0 comments on commit fa3b2f0

Please sign in to comment.