From ab9b070eb05c107f920f6e8d3f8ca7f058307222 Mon Sep 17 00:00:00 2001 From: Sergej-Vlasov <37613182+Sergej-Vlasov@users.noreply.github.com> Date: Mon, 8 Dec 2025 16:34:21 +0000 Subject: [PATCH] VariablesEditView: Update cloned variable key when duplicating (#114908) update cloned variable key when duplicating --- .../dashboard-scene/settings/VariablesEditView.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/app/features/dashboard-scene/settings/VariablesEditView.tsx b/public/app/features/dashboard-scene/settings/VariablesEditView.tsx index 2d5152b175e..8372837436b 100644 --- a/public/app/features/dashboard-scene/settings/VariablesEditView.tsx +++ b/public/app/features/dashboard-scene/settings/VariablesEditView.tsx @@ -1,4 +1,5 @@ import { useMemo } from 'react'; +import { v4 as uuidv4 } from 'uuid'; import { NavModel, NavModelItem, PageLayoutType } from '@grafana/data'; import { SceneComponentProps, SceneObjectBase, SceneVariable, SceneVariables, sceneGraph } from '@grafana/scenes'; @@ -109,10 +110,8 @@ export class VariablesEditView extends SceneObjectBase i newName = `copy_of_${variableToUpdate.state.name}_${copyNumber}`; } - //clone the original variable - const newVariable = variableToUpdate.clone(variableToUpdate.state); - // update state name of the new variable - newVariable.setState({ name: newName }); + //clone the original variable, update name and key + const newVariable = variableToUpdate.clone({ ...variableToUpdate.state, name: newName, key: uuidv4() }); const updatedVariables = [ ...variables.slice(0, variableIndex + 1),