diff --git a/x-pack/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/plugins/lens/public/app_plugin/app.test.tsx index a4137aa0407ba..87000865850e1 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.test.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.test.tsx @@ -1272,6 +1272,26 @@ describe('Lens App', () => { ); }); + it('updates the query if saved query is selected', () => { + const { component } = mountWith({}); + act(() => { + component.find(TopNavMenu).prop('onSavedQueryUpdated')!({ + id: '2', + attributes: { + title: 'new title', + description: '', + query: { query: 'abc:def', language: 'lucene' }, + }, + }); + }); + expect(TopNavMenu).toHaveBeenCalledWith( + expect.objectContaining({ + query: { query: 'abc:def', language: 'lucene' }, + }), + {} + ); + }); + it('clears all existing unpinned filters when the active saved query is cleared', () => { const { component, frame, services } = mountWith({}); act(() => diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx index e30fcda40276c..f137047cfc871 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.tsx @@ -692,6 +692,7 @@ export function App({ setState((s) => ({ ...s, savedQuery: { ...savedQuery }, // Shallow query for reference issues + query: savedQuery.attributes.query, })); }} onClearSavedQuery={() => {