From 7def66fdb6db40833c2a8573fb4feb1372d5fdc9 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 19 Oct 2021 14:41:30 +0100 Subject: [PATCH] Variables: Improve display when selecting variables with the same value (#40607) (#40630) * Variables: Allow selection of different variables with the same value * Variables: Don't modify this key (cherry picked from commit e48d77b1ebefc6a19bb5a30d8a9b1744e2601be9) Co-authored-by: Ashley Harrison --- .../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 = []; }