[Bug-2190]Perspective 8.0.16 Dropdown


I can pre-populate the selected values(Green) and the user can add more. What I need is a way to protect the pre-populated ones from being removed. Can you nudge me in the right direction?

Hi @jim_lapratt, how is the binding configured and how are you allowing the user to remove the values?

Can you not put an if statement in the delete function to check for those values (and also do something similar on the add side to prevent duplicates)?

Binding is standard from a dataset. Functionality is all standard dropdown. Is there a way to disallow the delete function once selected in a dropdown? I don’t see it.

@jim_lapratt, apologies I’m just trying to make sure I understand the issue correctly, but what is the binding on the props.value?

I have good news and I have bad news.

Good news:
Every option in options has a property available to it: isDisabled. This property is used to prevent users from interacting with the option, even though the option is still displayed in the dropdown. In theory, this would allow you to specify the options as part of the value, then make the option disabled by setting the isDisabled property to true. This setup would prevent a user from removing the selected option because it is now disabled.

(Screenshot taken in 8.1.4, though the property has existed since at least mid 8.0.X. I’ve reached out to our Documentation team to add it to the docs.)

Bad news:
While attempting to set this up so that I could relay a clear example and walkthrough, I found that the isDisabled property is currently only preventing selection of a property, and is failing to prevent de-selection. I’ve opened a ticket to fix this issue, and so the “officially recommended” avenue won’t work as of right now.

Any current solution is going to require some logic in a property change script on the value of the dropdown.

For example:

required_values = [1002, 96, 98]
all_present = True
for _rv in required_values:
    if _rv not in currentValue.value:
        all_present = False
if all_present:
    return currentValue.value
return previousValue.value

Update: cleaner logic

if all(elem in currentValue.value  for elem in [1002, 96, 98]):
    return currentValue.value
return previousValue.value