diff --git a/public/app/features/dashboard-scene/scene/PanelGroupByAction.tsx b/public/app/features/dashboard-scene/scene/PanelGroupByAction.tsx index d4bd11e7a87..0ab566c39a0 100644 --- a/public/app/features/dashboard-scene/scene/PanelGroupByAction.tsx +++ b/public/app/features/dashboard-scene/scene/PanelGroupByAction.tsx @@ -10,6 +10,7 @@ import { sceneGraph, SceneObjectBase, VariableValueOption, + VariableValueSingle, VizPanel, } from '@grafana/scenes'; import { Button, Icon, Input, useStyles2, Checkbox, Dropdown, Stack } from '@grafana/ui'; @@ -107,15 +108,21 @@ function PanelGroupByActionRenderer({ model }: SceneComponentProps { - const checkedOptions = options.filter((opt) => opt.checked); + const selectedValues: VariableValueSingle[] = []; + const selectedLabels: string[] = []; - if (!checkedOptions.length) { + for (const option of options) { + if (option.checked) { + selectedValues.push(option.value); + selectedLabels.push(option.label); + } + } + + if (!selectedValues.length) { return; } const groupByVariable = model.getGroupByVariable(); - const selectedValues = checkedOptions.map((item) => item.value); - const selectedLabels = checkedOptions.map((item) => item.label); if (groupByVariable) { groupByVariable.changeValueTo(selectedValues, selectedLabels, true);