question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow passing an entire object to AutoCompleteItem as the value

See original GitHub issue

Overview

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:closed
  • Created 2 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
anubra266commented, Jan 27, 2022

Thanks @SpencerKaiser we could add a new key that holds the full object.

1reaction
anubra266commented, Sep 27, 2021

Hi @jamesopti, really sorry it took the long. Just finished my exams. The value prop now accepts objects, and the getValue prop is now available to resolve the value used by default. If the getValue 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found