diff --git a/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx b/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx index 86e26e3bc..35672205f 100644 --- a/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx +++ b/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx @@ -68,6 +68,8 @@ function DashboardView(props: Props) { onAddWidgets(); trimQuery(); } + + return () => dashboardStore.resetSelectedDashboard() }, []); useEffect(() => { diff --git a/frontend/app/mstore/dashboardStore.ts b/frontend/app/mstore/dashboardStore.ts index 2df572264..36a34cbdb 100644 --- a/frontend/app/mstore/dashboardStore.ts +++ b/frontend/app/mstore/dashboardStore.ts @@ -216,9 +216,9 @@ export default class DashboardStore { syncDashboardInfo(id: string, info: { name: string, description: string, isPublic: boolean, createdAt: number }) { if (this.selectedDashboard !== null) { this.selectedDashboard.updateInfo(info) - const index = this.dashboards.findIndex((d) => d.dashboardId === id); - this.dashboards[index].updateInfo(info); } + const index = this.dashboards.findIndex((d) => d.dashboardId === id); + this.dashboards[index].updateInfo(info); } saveMetric(metric: Widget, dashboardId: string): Promise { @@ -320,6 +320,10 @@ export default class DashboardStore { } }; + resetSelectedDashboard = () => { + this.selectedDashboard = null + } + setSiteId = (siteId: any) => { this.siteId = siteId; };