diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx index 911d143d4b472..4ec7e8331b4d8 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx @@ -275,13 +275,11 @@ describe('Lens App', () => { it('loads a document and uses query and filters if there is a document id', async () => { const args = makeDefaultArgs(); args.editorFrame = frame; - const savedFilter = { query: { match_phrase: { src: 'test' } }, $state: { store: esFilters.FilterStateStore.APP_STATE }, meta: { disabled: false, negate: false, alias: null }, }; - (args.docStorage.load as jest.Mock).mockResolvedValue({ id: '1234', expression: 'valid expression', @@ -770,7 +768,6 @@ describe('Lens App', () => { const indexPattern = ({ id: 'index1' } as unknown) as IIndexPattern; const field = ({ name: 'myfield' } as unknown) as IFieldType; - await waitForPromises(); const filter = { ...esFilters.buildExistsFilter(field, indexPattern), $state: { store: esFilters.FilterStateStore.APP_STATE }, diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx index 036ef2dd54d0f..ca2c7e02c2d9c 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx @@ -75,18 +75,16 @@ export function App({ fromDate: currentRange.from, toDate: currentRange.to, }, + filters: data.query.filterManager.getFilters(), }; }); const { lastKnownDoc } = state; useEffect(() => { - // Clear app-specific filters when navigating to Lens. Necessary because Lens - // can be loaded without a full page refresh, using the same singleton - if (data.query.filterManager.getAppFilters().length) { + if (data.query.filterManager.getAppFilters().length > 0) { data.query.filterManager.setFilters(data.query.filterManager.getGlobalFilters()); } - const filterSubscription = data.query.filterManager.getUpdates$().subscribe({ next: () => { // Trigger a re-render, since filters are no longer tracked on state @@ -128,7 +126,6 @@ export function App({ core.notifications ) .then(indexPatterns => { - // Keep any pinned filters and set app filters from doc data.query.filterManager.setFilters( data.query.filterManager .getGlobalFilters()