diff --git a/src/plugins/data/public/ui/saved_query_flyouts/open_saved_query_flyout.tsx b/src/plugins/data/public/ui/saved_query_flyouts/open_saved_query_flyout.tsx index 41aa344bbaef..96848cfdba89 100644 --- a/src/plugins/data/public/ui/saved_query_flyouts/open_saved_query_flyout.tsx +++ b/src/plugins/data/public/ui/saved_query_flyouts/open_saved_query_flyout.tsx @@ -302,7 +302,9 @@ export function OpenSavedQueryFlyout({ if (selectedQuery) { if ( // Template queries are not associated with data sources. Apply data source from current query - selectedQuery.attributes.isTemplate + selectedQuery.attributes.isTemplate || + // Associating a saved query with a data source is optional. If no data source is present, keep the current source. + !selectedQuery.attributes.query.dataset?.dataSource ) { const updatedQuery: Query = { ...queryStringManager?.getQuery(),