From 370f4c2bcdf0ead2d0034f38faf837644152882a Mon Sep 17 00:00:00 2001 From: Oscar Kilhed Date: Thu, 3 Apr 2025 15:28:45 +0200 Subject: [PATCH] Dynamic dashboards: Use addNewRow and addNewTab when duplicating rows and tabs (#103362) Use addNewRow and addNewTab when duplicating rows and tabs --- .../dashboard-scene/scene/layout-rows/RowsLayoutManager.tsx | 3 +-- .../dashboard-scene/scene/layout-tabs/TabsLayoutManager.tsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/public/app/features/dashboard-scene/scene/layout-rows/RowsLayoutManager.tsx b/public/app/features/dashboard-scene/scene/layout-rows/RowsLayoutManager.tsx index 7f1100f3ed3..b2da3a617f3 100644 --- a/public/app/features/dashboard-scene/scene/layout-rows/RowsLayoutManager.tsx +++ b/public/app/features/dashboard-scene/scene/layout-rows/RowsLayoutManager.tsx @@ -90,8 +90,7 @@ export class RowsLayoutManager extends SceneObjectBase i public duplicateRow(row: RowItem) { const newRow = row.duplicate(); - this.setState({ rows: [...this.state.rows, newRow] }); - this.publishEvent(new NewObjectAddedToCanvasEvent(newRow), true); + this.addNewRow(newRow); } public addNewRow(row?: RowItem): RowItem { diff --git a/public/app/features/dashboard-scene/scene/layout-tabs/TabsLayoutManager.tsx b/public/app/features/dashboard-scene/scene/layout-tabs/TabsLayoutManager.tsx index 3de76a2e053..039a889ec21 100644 --- a/public/app/features/dashboard-scene/scene/layout-tabs/TabsLayoutManager.tsx +++ b/public/app/features/dashboard-scene/scene/layout-tabs/TabsLayoutManager.tsx @@ -70,7 +70,7 @@ export class TabsLayoutManager extends SceneObjectBase i public duplicateTab(tab: TabItem) { const newTab = tab.duplicate(); - this.setState({ tabs: [...this.state.tabs, newTab] }); + this.addNewTab(newTab); } public getUrlState() {