-
Notifications
You must be signed in to change notification settings - Fork 116
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
Pressing Enter doesn't call onSelect #6
Comments
We try to keep the plugin as simple and efficient as possible. Therefore, the onSelect callback is only fired on mouse click/select. From the docs: AFAICS, the callback has just one use case: You can submit the form on select. That's how we use it on Pixabay. By doing that, the mouse click has an identical behavior like pressing enter on a regular form. As it is, the plugin doesn't interfere in the normal form field behavior. The form gets submitted when pressing enter. Additionally, you can bind all kinds of event handler on the input field directly. So, it's intentional, but we might change this if it's important. It doesn't involve a lot of overhead, but some ... Closing the issue for now. |
I don't think any of those options work for my use case. I want to get a callback whenever a suggestion is selected. It has nothing to do with submitting the form. If #8 is merged, then when you click a suggestion, |
See #9. |
Yes, it's simple to add and it wouldn't cause a lot of overhead. We would include this feature right away if a few people preferred to have it. I think it can be useful and maybe it's even important to always fire the onSelect callback. But it's also important to keep the plugin as tiny as possible. There are quite a few suggester plugins available with lots and lots of options, but they usually come with the price of a huge code base, e.g. jQuery UI autocomplete: http://jqueryui.com/autocomplete/ We'll definitely think about it - and if others join in, we'll certainly include the feature! |
I think onSelect should always be triggered when something is selected, why not? |
👍 |
+1 for onSelect being triggered by pressing Enter. |
For those looking, the devbridge autocomplete plugin has this behaviour by default, I have put together heavily commented codepen demo here. |
I can't even find
13
(the keycode forenter
) anywhere in the code. It does put the item's text in the field, but I can't see where it does that.The text was updated successfully, but these errors were encountered: