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 e48d77b1eb)

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2021-10-19 15:41:30 +02:00
committed by GitHub
co-authored by Ashley Harrison
parent 7ac477ab48
commit 7def66fdb6
@@ -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 = [];
}