Select should return a single value if multiple is false #2721
RomainMazB
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
🚀 Feature request
The actual Zag API for the Select state machine always returns an array, despite the fact multiple option is false or true. Even when no value is selected, it returns a non-falsy value(
Boolean([]) === true
).🧱 Problem Statement / Justification
The most basic HTML5 select tag returns a single value when the multiple attribute is not set.
And you need extra code to retrieve the array of selected values when multiple attribute is set.
Example as a JSFiddle
The HTML W3C Standards states that the value
returns the value of the first selected item, if any, or the empty string if there is no selected item
.With this in mind, my expectations for the Zag Select state machine would have been to return a basic string value in its most basic form, which is not the case.
✅ Proposed solution or API
value: string[]|string
🤘↩️ Alternatives
The current only alternative is to "override" in the project component the state machine to select the
value[0]
when multiple is false. I don't feel comfortable with this because I don't want to add extra code to actually "regress" the state machine to its most basic form.Extra code is for enhancement, not regression.
📝 Additional Information
Reka UI (formerly Radix Vue) does that
Beta Was this translation helpful? Give feedback.
All reactions