From ad28e3cc77a99da82c17ad648af83e51b18aff84 Mon Sep 17 00:00:00 2001 From: kay delaney <45561153+kaydelaney@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:01:17 +0000 Subject: [PATCH] Scenes: Fix panel repeats (#83707) --- .../app/features/dashboard-scene/panel-edit/PanelEditor.tsx | 6 +++--- .../features/dashboard-scene/panel-edit/VizPanelManager.tsx | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx b/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx index c44cace8a18..ad1494a38e0 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx @@ -138,7 +138,7 @@ export class PanelEditor extends SceneObjectBase { width: repeatDirection === 'h' ? 24 : gridItem.state.width, height: gridItem.state.height, itemHeight: gridItem.state.height, - source: panelManager.state.panel.clone(), + source: panelManager.getPanelCloneWithData(), variableName: panelManager.state.repeat!, repeatedPanels: [], repeatDirection: panelManager.state.repeatDirection, @@ -157,7 +157,7 @@ export class PanelEditor extends SceneObjectBase { } const panelManager = this.state.vizManager; - const panelClone = panelManager.state.panel.clone(); + const panelClone = panelManager.getPanelCloneWithData(); const gridItem = new SceneGridItem({ key: panelRepeater.state.key, x: panelRepeater.state.x, @@ -189,7 +189,7 @@ export class PanelEditor extends SceneObjectBase { } panelRepeater.setState({ - source: panelManager.state.panel.clone(), + source: panelManager.getPanelCloneWithData(), repeatDirection: panelManager.state.repeatDirection, variableName: panelManager.state.repeat, maxPerRow: panelManager.state.maxPerRow, diff --git a/public/app/features/dashboard-scene/panel-edit/VizPanelManager.tsx b/public/app/features/dashboard-scene/panel-edit/VizPanelManager.tsx index 1570468ea27..f2433db7f95 100644 --- a/public/app/features/dashboard-scene/panel-edit/VizPanelManager.tsx +++ b/public/app/features/dashboard-scene/panel-edit/VizPanelManager.tsx @@ -367,6 +367,10 @@ export class VizPanelManager extends SceneObjectBase { return { error: 'Unsupported panel parent' }; } + public getPanelCloneWithData(): VizPanel { + return this.state.panel.clone({ $data: this.state.$data?.clone() }); + } + public static Component = ({ model }: SceneComponentProps) => { const { panel, tableView } = model.useState(); const styles = useStyles2(getStyles);