Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onChange not fired when user presses Enter #584

Closed
hillc5 opened this issue Oct 11, 2018 · 1 comment
Closed

onChange not fired when user presses Enter #584

hillc5 opened this issue Oct 11, 2018 · 1 comment

Comments

@hillc5
Copy link

hillc5 commented Oct 11, 2018

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

  1. Open Dev Tools on Codepen
  2. Type c, and wait for suggestions to appear
  3. Press Down to highlight selection
  4. 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

@moroshko
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants