Color field options: mixing entries with and without text causes panel error

Hi,

I noticed a small issue with the color field when using options.

If all options only define a value, it works:

options:
  -
    value: '#bf2d2d'
  -
    value: '#5b1355'

If all options define both value and text, it also works:

options:
  -
    value: '#bf2d2d'
    text: lorem
  -
    value: '#5b1355'
    text: ipsum

But if the options mix entries with and without text, the panel throws a console error and the field doesn’t appear:

options:
  -
    value: '#bf2d2d'
  -
    value: '#5b1355'
    text: ipsum

The error also occurs if one of the text value is null

Is this expected behavior or could this be a bug?

Thanks!

From looking at the code, the current behavior appears to be consistent with the implementation. The color field determines the format of the options array based on the first entry, so with a mixed value / value + text setup, the resulting behavior seems expected according to the current logic.

That said, it would still be good to clarify whether this is an intentional product decision or an edge case that should be handled more gracefully. @distantnative, would you consider this intended behavior, or would you expect a more tolerant fallback/validation here?

In my case for exemple, i used the mode: picker which supports the possibility to have à text associated to colors.

The text of the value is an optional attribute, i find it weird that if i want to give a text to only one value of the array i need to give a text to all other values otherwise the field stop functioning at all despite the text being optional at the beginning.

That’s just my opinion.