From 4897121fd828cf17fc0b346db5c2a2ab0d0a04a9 Mon Sep 17 00:00:00 2001 From: Maksym Tsymbarov Date: Fri, 4 Dec 2026 11:07:42 +0100 Subject: [PATCH] Fixed "Navigate to other dashboard" opening the target dashboard in its root state without the entity when the dashboard page is reused --- .../dashboard-page/states/state-controller.component.ts | 4 ++++ .../dashboard-page/states/state-controller.models.ts | 1 + .../dashboard-page/states/states-component.directive.ts | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.component.ts index 5f46b0f528..072d180dec 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.component.ts @@ -79,6 +79,10 @@ export abstract class StateControllerComponent implements IStateControllerCompon return this.statesValue; } + public replaceStates(states: { [id: string]: DashboardState }) { + this.statesValue = states; + } + currentState: string; syncStateWithQueryParam: boolean; diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.models.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.models.ts index a0666bf83d..47b2b39a50 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.models.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.models.ts @@ -15,4 +15,5 @@ export interface IStateControllerComponent extends IStateController { dashboardId: string; preservedState: any; init(): void; + replaceStates(states: {[id: string]: DashboardState }): void; } diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/states/states-component.directive.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/states/states-component.directive.ts index 7bff7b93a8..fd4d9d869a 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/states/states-component.directive.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/states/states-component.directive.ts @@ -71,13 +71,20 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges { ngOnChanges(changes: SimpleChanges): void { let reInitController = false; let initController = false; + const dashboardIdChange = changes.dashboardId; + const dashboardChanged = !!dashboardIdChange && !dashboardIdChange.firstChange && + dashboardIdChange.currentValue !== dashboardIdChange.previousValue; for (const propName of Object.keys(changes)) { const change = changes[propName]; if (!change.firstChange && change.currentValue !== change.previousValue) { if (propName === 'statesControllerId') { this.reInit(); } else if (propName === 'states') { - this.stateControllerComponent.states = this.states; + if (dashboardChanged) { + this.stateControllerComponent.replaceStates(this.states); + } else { + this.stateControllerComponent.states = this.states; + } } else if (propName === 'dashboardId') { this.stateControllerComponent.dashboardId = this.dashboardId; reInitController = true;