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

Trigger event with query when Enter key is pressed

Open cleercode opened this issue 10 years ago • 3 comments

I'd like to be able to retrieve the query even when the Enter key is pressed, even when an autocomplete option isn't selected, so that the user can submit queries that aren't in the autocomplete options.

cleercode avatar Mar 08 '15 00:03 cleercode

HI @cleercode! I have a PR for this improvement. I think its functionality is adaptable to your issue. https://github.com/reactjs/react-autocomplete/pull/83

emilianosanti avatar Mar 23 '16 01:03 emilianosanti

I really would like that functionality, too. In my scenario the user can select from a number of options but should also be able to add new items. At least in some cases so the discussed "onSearch" handler would be optimal for me.

Any chance that pull request might get merged?

Badestrand avatar Mar 04 '17 04:03 Badestrand

I would argue that this is input behavior, not autocomplete behavior. You can easily handle this use case by catching "enter" keypresses in the input's onKeyUp handler and performing your logic with the input value.

vincentbello avatar Jan 17 '18 21:01 vincentbello