Let us use the same structure as in #3575402: Cannot inject (raw) values from List (text) field into string enum prop. We observe that, for an enum prop such as bgColor, we cannot use "Token" as source, whereas this is possible for a normal string prop (such as Symbol ID in the screenshot).

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fmb created an issue. See original summary.

nickolaj made their first commit to this issue’s fork.

nickolaj’s picture

Status: Active » Needs review

Added 'enum' to TokenSource's prop_types array so that Token can be used as a source for enum (List text) properties, matching the existing support for string, slot, and url prop types.

fmb’s picture

Status: Needs review » Reviewed & tested by the community

Yes, it works!

just_like_good_vibes made their first commit to this issue’s fork.

just_like_good_vibes’s picture

Hello,
thank you for reporting and proposing this modification.

Indeed, we took a decision in how to handle enum props.
there is today no source with "free" input, like token or a textfield to set a value for an enum.
we have instead "select" or other field related sources.

So here, in this MR, what is proposed is to open the way for new sources with free input to be used to set a value on an enum prop.
obvious for an advanced site builder which can use tokens, less obvious for less experienced users, especially when the component prop form is appearing outside of ui patterns component form (e.g. display_builder for example).

i think i would like to discuss that point with other maintainers before merging.

i know we have this already existing mechanism, which would reset the value if the provided value is not part of the enum, but as i tried to explain, the initially restricted list of source available had the purpose of forcing/guiding the user to input only possible values.

just_like_good_vibes’s picture

Status: Reviewed & tested by the community » Postponed

Hello,
thanks for your proposal, we agree there is a need here.
However, we still need time to evaluate how confusing it can for low-power users if we open the source token (or any other free input source)
to enum props . in the meantime, in any case of a specific need like that one, we advise to write a small custom ui patterns source.