osu-framework: Allow dropdown to handle invalid values

A Dropdown will currently fault when the underlying Bindable is updated to a value not present in the dropdown.

Here are two ideas to circumvent this:

  • Add the “invalid” value as a temporary DropdownMenuItem and delete it once the selection is changed. This would allow to display the selected value temporarily and allow the user to keep it (which may or may not be desirable depending on the situation)
  • Restore the “default” value and update the Bindable accordingly. Could be either a fallback to the first item in the list or an optional delegate to retrieve a valid value from an invalid one (more flexible). This might result in an infinite feedback loop of Bindable updates if used improperly.

Causes ppy/osu#3474

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 29 (29 by maintainers)

Most upvoted comments

Give it a shot

I took that as meaning to display the invalid value, as if it were a valid value. Which I think is the way to go as both macOS and Windows do this.