Plugin Builder Bug: Color Picker Default Cannot be Set to Null for Optional Color Field

Well, here’s a super-annoying bug in plugin builder:

Though you can create a field with a color selector that is marked Optional, the color picker in the plugin builder will not allow you to select a null (empty) color:

It always insists on dropping a hex value in there. (This is different from the color picker in the editor/element interface, which DOES allow selection of null.)

So this makes it impossible to handle “optional” colors in an efficient way. Of course, what you’d want to do is have those fields null by default and then use the value if one is present, like:

!properties.hover_text_color ? instance.data.hover_text_color = 'inherit' : instance.data.hover_text_color = properties.hover_text_color

1 Like

There is a workaround that is itself annoying: You can take one of those fields (e.g., my picked_text_color field shown in the snip above), and make it’s editor type static text, which will null out the default field.

Now switch the editor type back to Color and do not dare touch the default field. The value will remain null.

(Note that your testing instance of your plugin element may have retained a value here and so you may need to nuke the field and recreate it to get rid of the stored value or do some other refresh shenanigans in your editor. YMMV.)

2 Likes

This topic was automatically closed after 14 days. New replies are no longer allowed.