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

Ability to listen to various events that aren't currently exposed #5

Open
trickeyone opened this issue May 29, 2015 · 5 comments
Open

Comments

@trickeyone
Copy link

I'm having to directly add a listener to the input element to listen for blur events so I can do a proper check for if a new value has actually been selected, either by hitting "Enter" or by clicking. It would be nice if there was an event for when the dropdown is closed, this way I know that the user is done.

@ezequiel
Copy link
Owner

Good point! How does onDropdownOpen and onDropdownClose sound?

@trickeyone
Copy link
Author

Sounds good to me. Maybe supply another passthrough for onBlur for the actual input element, too?

@ezequiel
Copy link
Owner

@trickeyone Thanks for the feedback. I've added the props onBlur, onDropdownOpen, and onDropdownClose in 0.5.0. Let me know if they work as expected. 🚀

Just as a note, blur is fired on Enter, or when an option is clicked, or when the user clicks somewhere outside of Typeahead

@trickeyone
Copy link
Author

Thanks, @ezequiel ! They look to work well. After a bit of messing around last week, the approach I ended up taking, actually, was to listen for the key down event on the input element. When the user pressed Enter, I looked for an update or when the used selected an option.

My case may be unique but the typeahead is being used as a search/suggestion display rather than a direct change to the input, so I needed to be able to wait for an actual selection from the dropdown list, thus the reason I need to actually listen for the "Enter" key being pressed and not the input element being blurred. I thought blurring would be sufficient but it did not supply the needed granularity to discern if a change had occurred. At this stage, adding an onEnter or onKeyDown (vs onKeyUp since the "Enter" key is not caught) would be more beneficial in my particular case.

As a note, the "Enter" key isn't being cause by the onKeyUp event because of the blur being called from your internal onKeyDown listener, hence my needing to listen for the same event.

@kushal
Copy link

kushal commented Dec 3, 2015

This widget is great, but I have a similar need to @trickeyone. I'd expect there to be an onOptionSelected which is fired either when Enter is pressed or when the user selects an option by clicking.

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

3 participants