Skip to content

Commit c2f53a9

Browse files
authored
[Search Sessions][Dashboard] Clear search session when navigating from dashboard route (#89749)
1 parent 4f43096 commit c2f53a9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/plugins/dashboard/public/application/dashboard_app.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ export function DashboardApp({
265265
};
266266
}, [dashboardStateManager, dashboardContainer, onAppLeave, embeddable]);
267267

268+
// clear search session when leaving dashboard route
269+
useEffect(() => {
270+
return () => {
271+
data.search.session.clear();
272+
};
273+
}, [data.search.session]);
274+
268275
return (
269276
<div className="app-container dshAppContainer">
270277
{savedDashboard && dashboardStateManager && dashboardContainer && viewMode && (

x-pack/test/send_search_to_background_integration/tests/apps/dashboard/async_search/send_to_background.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
9696
// should leave session state untouched
9797
await PageObjects.dashboard.switchToEditMode();
9898
await searchSessions.expectState('restored');
99+
100+
// navigating to a listing page clears the session
101+
await PageObjects.dashboard.gotoDashboardLandingPage();
102+
await searchSessions.missingOrFail();
99103
});
100104
});
101105
}

0 commit comments

Comments
 (0)