Allow passing an entire object to AutoCompleteItem as the value
See original GitHub issueOverview
It’s very common to use a component like this with a list of objects. While the input value is always a string, it would be nice to also pass the entire object to AutoComplete
and invoke the onSelectOption
with that value.
Example
<AutoComplete
// This is a hack to reset the internal state of the component
key={instanceCount}
...
onSelectOption={(selection) => {
// selection is { email: 'you@me.com', id: 's3e8d' }
}}
>
...
<AutoCompleteItem
key={item.email}
value={{ email: 'you@me.com', id: 's3e8d' }}
/>
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
How to pass whole object to input from md-autocomplete ...
To make this work, create a function on your component class that maps the control value to the desired display value. Then bind...
Read more >Autocomplete: for selected object, return individual property ...
An Autocomplete component being capable of returning an individual property value (like id ) from a selected object, if specified.
Read more >Autocomplete: is there a way to v-model the value
Hi team, Is there a way to v-model autocomplete value to a property in the corresponding data object? Standard way does not work:...
Read more >Place Autocomplete | Places API - Google Developers
Defines the distance (in meters) within which to return place results. You may bias results to a specified circle by passing a location...
Read more >Svelecte - select with autocomplete written in Svelte
By default it converts plain string items to object with value and label properties. ... Specify which property is used as value. This...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @SpencerKaiser we could add a new key that holds the full object.
Hi @jamesopti, really sorry it took the long. Just finished my exams. The
value
prop now accepts objects, and thegetValue
prop is now available to resolve the value used by default. If thegetValue
prop does not exist and you pass an object as the value, the first key in the value is used. See changes in v4.8.0