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

Select support does't support object value #30066

Closed
2 tasks done
hamcher opened this issue Dec 5, 2021 · 3 comments
Closed
2 tasks done

Select support does't support object value #30066

hamcher opened this issue Dec 5, 2021 · 3 comments
Labels
status: waiting for author Issue with insufficient information

Comments

@hamcher
Copy link

hamcher commented Dec 5, 2021

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Select support only integer and string value, but i can't use value as object, because some times we need it to use it in a specific case

   <MenuItem value={{ id: 20, name: 'apple'}}>Apple</MenuItem>

Expected behavior 🤔

No response

Steps to reproduce 🕹

No response

Context 🔦

No response

Your environment 🌎

No response

@hamcher hamcher added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 5, 2021
@mnajdova
Copy link
Member

mnajdova commented Dec 6, 2021

@hamcher what is the specific case where you need this? What do you need it specifically on the MenuItem?

@mnajdova mnajdova added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 6, 2021
@RyanClementsHax
Copy link

I cant speak for @hamcher, but I have a case where uniqueness between the objects the select is representing is derived from multiple fields (i.e. composite key). Instead of serializing the fields into one key to use for the value in the MenuItem component, then deserializing it when handling the change event in the onChange handler of the Select component, it would be handy if I could just use the object itself as the key.

A work around for my issue is to add an additional field (immutably or mutably) with the serialized composite key, then to use that serialized key for the value. This isn't ideal when using typescript, but is an ok workaround none the less.

@mnajdova
Copy link
Member

mnajdova commented Dec 7, 2021

I would say that is better than using an object. It is what you would do if you were to use plain HTML. If you have some kind of identifier for the item, you could use that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

4 participants