From 43a1fa53aab61c0b9e6844602ee503f1705ca238 Mon Sep 17 00:00:00 2001 From: SagarRajput-7 <162284829+SagarRajput-7@users.noreply.github.com> Date: Sat, 15 Feb 2025 00:23:33 +0530 Subject: [PATCH] fix: fixed selected value getting reset for variables and refetch not going (#7115) --- .../DashboardVariablesSelection/VariableItem.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx b/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx index 7e6c050653..4b3a962ef9 100644 --- a/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx +++ b/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx @@ -150,11 +150,13 @@ function VariableItem({ let allSelected = false; // The default value for multi-select is ALL and first value for // single select - if (variableData.multiSelect) { - value = newOptionsData; - allSelected = true; - } else { - [value] = newOptionsData; + if (valueNotInList) { + if (variableData.multiSelect) { + value = newOptionsData; + allSelected = true; + } else { + [value] = newOptionsData; + } } if (variableData && variableData?.name && variableData?.id) { @@ -226,6 +228,9 @@ function VariableItem({ } setErrorMessage(message); } + setVariablesToGetUpdated((prev) => + prev.filter((v) => v !== variableData.name), + ); }, }, );