Multiselect Custom Value Option Color

I have a multiselect component that populates its options from a query, and it also allows custom values to be input.

What I'd like to do is color all the options that are already in the database the same default color (in this example green), and then I'd like to color custom value options that have added a different color (in this example red). I'd like to do this so that the end user has an indication that they're about to add something new to the database.

Something like this:

The only way I've kinda figured out how to do this is:

  1. Set the same default color for every mapped option:

  2. Set the style for the default color of Tags to the color I want shown for new custom value options:

This is annoying, because then I have unnecessary color dots on every menu item in the list:

I thought maybe I could get rid of those with some CSS, but doesn't seem possible.

I also through maybe I could programmatically set the color in the Styles section based on some condition, but it doesn't seem to work that way.

Anyone got ideas for a better solution?

Check out this post:
There are some ways you can implement what you want to do

@ScottR, hmm, everything in that post seems to deal with the Tag Dropdown column type in a table. However, I'm dealing with a multiselect component, so I don't understand how anything in that post is relevant to the issue I have.

@benbarry I assumed you would have understood that a ternary operator could be used. I assumed incorrectly, so my apologies.

The logic still applies though, does it not? - Why can't you use a ternary operator to determine what already exists and set that to green and if it is new then set the color to red?

@ScottR I'm just not sure where you're proposing that I use a ternary operator.

Using it in the mapped options would be pointless, since every option there is already in the database.

And, it doesn't seem that I can use a ternary in the Styles section to set the tag color for each item. It seems like the Style just sets a default globally for that component, and something like item or i is not available to be used.

Like, I totally understand that I could use a ternary in a situation like this. In this particular database there is a type field, and I could color each tag based on that type in the mapped options.

However, that's not the issue I'm having.

I just want to color new custom values a unique color without adding the color dots to the menu for items that already exist.

What I want (I think) is essentially something like this:

Actually based on what you added above the solution is

{{!YourMappedResourceName.value.includes(self.value[i])?'red':'green'}}

In the Tags Styles field

Screen Shot 2022-11-23 at 11.35.18 AM

@ScottR I had tried something similar to this yesterday. It seems like maybe you're getting a different behavior than I am though, and I don't understand why (feel like maybe I'm missing something obvious).

I recorded a quick screencast of the behavior I'm getting:

Hmmm you know what even if I remove the ! in it and say if true then green if not red I am now running into the same issue as you... Could be a bug I just find it odd that it worked a few minutes ago and now it isn't.... I'll keep pecking away and see where I get...

Thanks for trying to help figure this out. This definitely feels like this should be the solution I'm after, and seems like a bug.

@benbarry
Got it

So it was a combo of my original but deleted solution and the one we both tried

In Color put in the logic to test if false using ! and in the Tags field add the same logic but checking if true

Screen Shot 2022-11-23 at 12.16.53 PM
Screen Shot 2022-11-23 at 12.17.03 PM

@ScottR, so this is functionally the same as the "solution" I had in my original post, and still not quite the behavior I desire. That original "solution" achieved this same result in a simpler way.

The issue here is that by adding color in the mapped options, it applies the little color dots in the dropdown list. Since they're all the same in this case, they don't provide any real utility and are just a visual distraction.

There seems to be no way to turn those dots off (either through the component inspector, or via overriding CSS).

Maybe I'm just being too OCD, but it bugs me.

hahahah nope all good man....
Well I guess we're back to square 1!
@victoria S.O.S. :slight_smile: :white_flag: