diff --git a/public/app/features/dashboard-scene/settings/JsonModelEditView.tsx b/public/app/features/dashboard-scene/settings/JsonModelEditView.tsx index 5cadfcbf48f..7397c6fdbe2 100644 --- a/public/app/features/dashboard-scene/settings/JsonModelEditView.tsx +++ b/public/app/features/dashboard-scene/settings/JsonModelEditView.tsx @@ -72,7 +72,7 @@ export class JsonModelEditView extends SceneObjectBase i // FIXME: We could avoid this call by storing the entire dashboard DTO as initial dashboard scene instead of only the spec and metadata const dto = await getDashboardAPI('v2').getDashboardDTO(result.uid); newDashboardScene = transformSaveModelSchemaV2ToScene(dto); - const newState = sceneUtils.cloneSceneObjectState(newDashboardScene.state); + const newState = sceneUtils.cloneSceneObjectState(newDashboardScene.state, { key: dashboard.state.key }); dashboard.pauseTrackingChanges(); dashboard.setInitialSaveModel(dto.spec, dto.metadata); @@ -83,7 +83,7 @@ export class JsonModelEditView extends SceneObjectBase i dashboard: jsonModel, meta: dashboard.state.meta, }); - const newState = sceneUtils.cloneSceneObjectState(newDashboardScene.state); + const newState = sceneUtils.cloneSceneObjectState(newDashboardScene.state, { key: dashboard.state.key }); dashboard.pauseTrackingChanges(); dashboard.setInitialSaveModel(jsonModel, dashboard.state.meta); @@ -91,6 +91,9 @@ export class JsonModelEditView extends SceneObjectBase i } this.setState({ jsonText: this.getJsonText() }); + + // We also need to resume tracking changes since the change handler won't see any later edit + dashboard.resumeTrackingChanges(); }; static Component = ({ model }: SceneComponentProps) => {