react-autocomplete icon indicating copy to clipboard operation
react-autocomplete copied to clipboard

How can I handle non suggested terms?

Open carpben opened this issue 7 years ago • 2 comments

I am looking for an autocomplete that can suggest options from a given list, but can also accept other options. However when I the AutoComplete component this property: onSelect={val => console.log(`selection val=${val}`)} And then in the browser I type into it and press enter, it will only call the function when there is a highlighted suggestion, and call it with the highlighted suggestion as an argument. Is there a way to use any term and with enter send that value?

carpben avatar May 06 '18 12:05 carpben

It seems I can't pass the component an onKeyPress property, to handle an enter press case.

carpben avatar May 06 '18 16:05 carpben

Hi, you can easily achieve this by using inputProps:

inputProps={{onKeyPress: (e)=>{
 if (e.key === 'Enter') {
  // do whatever
 }
}}}

0xori avatar Aug 08 '18 12:08 0xori