grafana/scenes

QueryVariables not getting sorted

Opened this issue · 0 comments

Function sortVariableValues in file scenes/packages/scenes/src/variables/variants/query/utils.ts seems unable to really sort variables.

It receives an options parameter typed as any[], although the real type options seem to be being passed as is VariableValueOption, as defined in the scenes/packages/scenes/src/variables/types.ts file:

export interface VariableValueOption {
  label: string;
  value: VariableValueSingle;
  group?: string;
}

Both sortByNumeric and sortByNaturalSort internal sort strategies defined inside the sortVariableValues function seem to try to sort options based on an attribute called text, but, as we can see, the VariableValueOption doesn't have any text attribute. It seems like sortByNumeric and sortByNaturalSort should be checking the label attribute instead. Is there any reason not to do that? Am I missunderstanding somehing?

Thank you.