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

Input setState different when onSuggestionSelected using keyboard or mouse #90

Closed
suite22 opened this issue Nov 20, 2015 · 4 comments
Closed

Comments

@suite22
Copy link

suite22 commented Nov 20, 2015

My use case might be outside your intended plans for the component, but I want the input to reset to an empty string instead of displaying the selected suggestion. Within onSuggestionSelected I'm using
this.setState({ value: "" }) to reset the input to an empty string. However, that only works if I make the selection using the keyboard. If the user clicks the suggestion the input value remains set to the selected suggestion.

I put together a quick example to illustrate the issue - http://codepen.io/suite22/pen/vNPqZX or https://gist.github.com/suite22/981a9c73dc7113d88283

I forked the repo to quickly get the behavior I need 4138bab, but I'm curious if this is expected behavior. I didn't make my change a PR because it does fail several of the asserts related to mouse selection behavior.

@moroshko
Copy link
Owner

@suite22 Yep, current version has some issues with controlled behaviour. But, hold tight, version 3.0 is on its way. It will support nicely flux architecture (including redux), and you'll be able to differentiate between pressing Enter and mouse click in onSuggestionSelected. I plan to release it in the next couple of weeks.

@moroshko moroshko added the hooks label Nov 22, 2015
@suite22
Copy link
Author

suite22 commented Nov 22, 2015

Awesome! Sounds great. Thanks!

@moroshko
Copy link
Owner

@suite22 Just wanted to let you know that 3.0 alpha version is available on npm:

npm install [email protected] --save

@suite22
Copy link
Author

suite22 commented Dec 24, 2015

Great! Thanks @moroshko

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