NSelect: no way to know the group of an option
See original GitHub issueThis function solves the problem (这个功能解决的问题)
If multiple SelectOption
in different SelectGroupOption
have the same value
, there is no way to distinguish which one the user have selected.
This problem happens with this really common use case:
- We fetch list
A
,B
andC
from API - Each list have their own id auto increment (dedicated table in database) and so there is the same ids in each list
- We want to use each list as a
SelectGroupOption
in the sameNSelect
- Because there is the same
value
(akaid
)1
(for example) in listA
,B
andC
, we have no way to know whichSelectOption
the user have selected 😭
Expected API (期望的 API)
A very flexible way of handling that could be a new option-as-value
boolean prop.
Once set to true
, the value
prop (and corresponding update:value
event) while now deal with the whole SelectOption
object instead of only the value
. Because it’s an object, it become easy to add a group
property which contains the corresponding SelectGroupOption
key
(or even the whole SelectGroupOption
object after all 🤷♂️).
In addition, if the developer provides extra properties to SelectOption
objects, he will be able to better identify which one is selected based on that extra properties.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
onUpdate:value
will pass original option as the second param.😱 😱 😱 Hoooo I’m sooooo sorry! I miss that part in the documentation!! I apology for the useless noise. Thanks a lot for your quick answer and patience 🤗 ❤️