From e48d77b1ebefc6a19bb5a30d8a9b1744e2601be9 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Tue, 19 Oct 2021 14:13:17 +0100 Subject: [PATCH] Variables: Improve display when selecting variables with the same value (#40607) * Variables: Allow selection of different variables with the same value * Variables: Don't modify this key --- .../app/features/variables/pickers/OptionsPicker/reducer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/features/variables/pickers/OptionsPicker/reducer.ts b/public/app/features/variables/pickers/OptionsPicker/reducer.ts index cece7d60714..4f70e2d3fa6 100644 --- a/public/app/features/variables/pickers/OptionsPicker/reducer.ts +++ b/public/app/features/variables/pickers/OptionsPicker/reducer.ts @@ -138,7 +138,7 @@ const optionsPickerSlice = createSlice({ const { multi, selectedValues } = state; if (option) { - const selected = !selectedValues.find((o) => o.value === option.value); + const selected = !selectedValues.find((o) => o.value === option.value && o.text === option.text); if (option.value === ALL_VARIABLE_VALUE || !multi || clearOthers) { if (selected || forceSelect) { @@ -153,7 +153,7 @@ const optionsPickerSlice = createSlice({ return applyStateChanges(state, updateDefaultSelection, updateAllSelection, updateOptions); } - state.selectedValues = selectedValues.filter((o) => o.value !== option.value); + state.selectedValues = selectedValues.filter((o) => o.value !== option.value && o.text !== option.text); } else { state.selectedValues = []; }