onChange not fired when user presses Enter
Description
when a user types a suggestion, highlights an option with up/down keys, then presses enter, the selection should trigger the onChange method in the inputProps object, as referenced here: https://www.npmjs.com/package/react-autosuggest#inputpropsonchange-required
CodePen: https://codepen.io/CharlesHill/pen/gBRzoq
Reproduction Steps
- Open Dev Tools on Codepen
- Type
c, and wait for suggestions to appear - Press Down to highlight selection
- Preass Enter to select
Observed behaviour: Nothing happens and nothing logs to the console
Expected behaviour: onChange should be called and 'enter' should be logged to the console
onChange is called only when the input value changes.
In your repro, the input value changes when you press Down, but not when you press Enter.
It will be called with method === "enter" if you hover a suggestion with a mouse (this doesn't change the input value), and then press Enter.
You might want to use onSuggestionSelected.