From 831c7176892376b6a778b2e2bbea89463f4c2379 Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 07:10:41 +0200 Subject: [PATCH] [v11.0.x] Dashboard scenes: fix textbox value only set to first character of default value (#86742) Dashboard scenes: fix textbox value only set to first character of default value (#86595) Dashboard scene: fix textbox value only set to first character in default value (cherry picked from commit dccad4e0811132e9d992e07faa4ad2048d50f2d3) Co-authored-by: Oscar Kilhed --- .../serialization/transformSaveModelToScene.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts b/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts index cdbcf461350..b89315a97af 100644 --- a/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts +++ b/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts @@ -392,9 +392,20 @@ export function createSceneVariableFromVariableModel(variable: TypedVariableMode hide: variable.hide, }); } else if (variable.type === 'textbox') { + let val; + if (!variable?.current?.value) { + val = variable.query; + } else { + if (typeof variable.current.value === 'string') { + val = variable.current.value; + } else { + val = variable.current.value[0]; + } + } + return new TextBoxVariable({ ...commonProperties, - value: variable?.current?.value?.[0] ?? variable.query, + value: val, skipUrlSync: variable.skipUrlSync, hide: variable.hide, });