From 3ca8a7ccc24eff97e0adc46c68decd8e3428fd71 Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 10:58:15 +0200 Subject: [PATCH] [v11.0.x] DataTrails: Do not create a new VizPanel every activation (#85774) --- .../trails/AutomaticMetricQueries/AutoVizPanel.tsx | 13 ++++++------- public/app/features/trails/MetricGraphScene.tsx | 4 +--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/public/app/features/trails/AutomaticMetricQueries/AutoVizPanel.tsx b/public/app/features/trails/AutomaticMetricQueries/AutoVizPanel.tsx index 75593018623..4572bf47f6a 100644 --- a/public/app/features/trails/AutomaticMetricQueries/AutoVizPanel.tsx +++ b/public/app/features/trails/AutomaticMetricQueries/AutoVizPanel.tsx @@ -20,10 +20,11 @@ export class AutoVizPanel extends SceneObjectBase { } public onActivate() { - const { autoQuery } = getMetricSceneFor(this).state; - this.setState({ - panel: this.getVizPanelFor(autoQuery.main), - }); + if (!this.state.panel) { + const { autoQuery } = getMetricSceneFor(this).state; + + this.setState({ panel: this.getVizPanelFor(autoQuery.main) }); + } } private getQuerySelector(def: AutoQueryDef) { @@ -43,9 +44,7 @@ export class AutoVizPanel extends SceneObjectBase { const def = metricScene.state.autoQuery.variants.find((q) => q.variant === variant)!; - this.setState({ - panel: this.getVizPanelFor(def), - }); + this.setState({ panel: this.getVizPanelFor(def) }); metricScene.setState({ queryDef: def }); }; diff --git a/public/app/features/trails/MetricGraphScene.tsx b/public/app/features/trails/MetricGraphScene.tsx index 7cb03d369ac..78ec601f135 100644 --- a/public/app/features/trails/MetricGraphScene.tsx +++ b/public/app/features/trails/MetricGraphScene.tsx @@ -72,8 +72,6 @@ function getStyles(theme: GrafanaTheme2) { } function buildGraphTopView() { - const bodyAutoVizPanel = new AutoVizPanel({}); - return new SceneFlexLayout({ direction: 'column', $behaviors: [new behaviors.CursorSync({ key: 'metricCrosshairSync', sync: DashboardCursorSync.Crosshair })], @@ -81,7 +79,7 @@ function buildGraphTopView() { new SceneFlexItem({ minHeight: MAIN_PANEL_MIN_HEIGHT, maxHeight: MAIN_PANEL_MAX_HEIGHT, - body: bodyAutoVizPanel, + body: new AutoVizPanel({}), }), new SceneFlexItem({ ySizing: 'content',