-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Searching mode for autocomplete #9
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
Searching mode for autocomplete #9
Conversation
When in searching mode autocomplete fires default action when no item is selected from dropdown menu.
This doesn't seem like something that belongs in the core of the plugin. You can easily listen for the enter key yourself. Also, a good guideline is that if an option is off by default, it doesn't belong in the core of the plugin. |
Yeah, I could listen to enter key, but checking if there is a menu item selected is surely painful from outside plugin. I don't fully understand your argument that if it's off by default it does not belong to core. There are so many counterexamples in jquery-ui itself I won't even start to enumerate them. |
Another example where this is basic behavior - www.google.com - I really do think this is pretty common behavior for searching autocomplete widget. Why do you think it should not belong to core? |
Those counterexamples will eventually be overhauled, based on what the button and autocomplete designs laid out. While it wouldn't help to just pull out those existing widgets, we can be strict on anything new. |
Anyway, in this case it looks like the change is generally useful and would reflect the Awesome Bar behaviour on which we designed most aspects of the autocomplete. We just don't need the option. |
Cool, any source code for the Awesome Bar? All I found is this http://code.google.com/p/jquery-utils/source/browse/trunk/src/ui.awesomebar.js?r=588 Thanks for creating the ticket. |
Add, should have clarified that. Was referring to Firefox' addressbar, which got called Awesome Bar when Firefox 3 was released. And it certainly is. |
Ok, thanks for the clarification on Awesome Bar. ;) So what's the plan? How do I add this behavior without adding an off-by-default option? These two behaviors are exclusive, one of them simply must be off. I could possibly do that by pushing this behavior to a subclass, but refactoring that switch would be a pain. |
The purpose of the ticket is that we just make the change in jQuery UI itself, without any option involved. If you want to help, send a new pull request with the extended if-statement (trivial) along with some more tests (the interesting part). Are you familiar with QUnit? |
I am familiar with unittesting, but not for JS. |
Implemented in adcafce |
I am using autocomplete for a basic search box (like the one on apple.com - upper right corner). What I wanted is to have options as I type but eventually to be able to submit my custom query (not normally what autocomplete is for I know).
I've added searching mode to autocompleter, that works like this: You add option searchingMode: true and on pressing enter the autocompleter checks if there is an item selected, if not, preventDefault is not triggered, thus normal form submit (or whatever) is triggered.
Hope this is helpful to anybody.