Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SelectOption.value to be of any type #5386

Open
MrRawbin opened this issue Nov 16, 2023 · 2 comments
Open

Allow SelectOption.value to be of any type #5386

MrRawbin opened this issue Nov 16, 2023 · 2 comments
Labels
feature request New feature or request

Comments

@MrRawbin
Copy link
Contributor

This function solves the problem (这个功能解决的问题)

Often when using a select menu, it is desirable to be able select any kind of value from a list of options. Currently, the only available options are string and number.

Consider a list of people:

const people: Array<Person> = [
  { id: 1, name: 'John Doe', age: 24 },
  { id: 2, name: 'Jane Doe', age: 25 },
]

In this case, we would have to use the id of the person as SelectOption value. When we select a user and want to do something with it, we then have to traverse the list of people and find the selected one by id, which is inefficient and leads to boilerplate code.

Expected API (期望的 API)

Using the people example above:

const selectOptions = people.map((person: Person) => ({ label: person.name, value: person }))
@github-actions github-actions bot added the feature request New feature or request label Nov 16, 2023
@realByg
Copy link

realByg commented Nov 24, 2023

could be usefule, kinda like the vuetify api https://v2.vuetifyjs.com/en/api/v-select/#props-return-object

@MrRawbin
Copy link
Contributor Author

Still believe this would be very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants