From e9b932c8f69c3d2f49c1cd9ae35b7dd6157c71e7 Mon Sep 17 00:00:00 2001 From: Darren Janeczek <38694490+darrenjaneczek@users.noreply.github.com> Date: Fri, 3 May 2024 14:29:54 -0400 Subject: [PATCH] datatrails: reloaded trail bugs related to no selected metric (#87344) * fix: reloaded scene first step topScene The top scene was not being initialized when reloading trails, causing it to use the top scene of whatever was selected previously. * fix: select new metric node not reloading right On reloading trails, any metric node that was 'green' with a undefined metric due to clicking on the "select new metric" button, was reloading with the metric of the step directly before it (in index order). --- public/app/features/trails/DataTrail.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/app/features/trails/DataTrail.tsx b/public/app/features/trails/DataTrail.tsx index e3150253c69..8375c23e3ba 100644 --- a/public/app/features/trails/DataTrail.tsx +++ b/public/app/features/trails/DataTrail.tsx @@ -169,6 +169,11 @@ export class DataTrail extends SceneObjectBase { public restoreFromHistoryStep(state: DataTrailState) { this.disableUrlSync(); + if (!state.topScene && !state.metric) { + // If the top scene for an is missing, correct it. + state.topScene = new MetricSelectScene({}); + } + this.setState( sceneUtils.cloneSceneObjectState(state, { history: this.state.history, @@ -213,7 +218,7 @@ export class DataTrail extends SceneObjectBase { if (this.state.metric !== values.metric) { Object.assign(stateUpdate, this.getSceneUpdatesForNewMetricValue(values.metric)); } - } else if (values.metric === null) { + } else if (values.metric == null) { stateUpdate.metric = undefined; stateUpdate.topScene = new MetricSelectScene({}); }