From e92e0b6e29d56c7704388d29ec0cec962d3293a2 Mon Sep 17 00:00:00 2001 From: SagarRajput-7 <162284829+SagarRajput-7@users.noreply.github.com> Date: Mon, 10 Mar 2025 14:18:55 +0530 Subject: [PATCH] fix: fixed handling of how and when to set ALL option (#7244) --- .../DashboardVariablesSelection/VariableItem.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx b/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx index 4b3a962ef9..f470eac26e 100644 --- a/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx +++ b/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx @@ -157,6 +157,13 @@ function VariableItem({ } else { [value] = newOptionsData; } + } else if (variableData.multiSelect) { + const { selectedValue } = variableData; + allSelected = + newOptionsData.length > 0 && + Array.isArray(selectedValue) && + selectedValue.length === newOptionsData.length && + newOptionsData.every((option) => selectedValue.includes(option)); } if (variableData && variableData?.name && variableData?.id) { @@ -235,8 +242,9 @@ function VariableItem({ }, ); - const handleChange = (value: string | string[]): void => { - // if value is equal to selected value then return + const handleChange = (inputValue: string | string[]): void => { + const value = variableData.multiSelect && !inputValue ? [] : inputValue; + if ( value === variableData.selectedValue || (Array.isArray(value) &&