Skip to content

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

Closed
wants to merge 1 commit into from
Closed

Searching mode for autocomplete #9

wants to merge 1 commit into from

Conversation

jsuchal
Copy link

@jsuchal jsuchal commented Sep 9, 2010

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.

When in searching mode autocomplete fires default action when no item is selected from dropdown menu.
@scottgonzalez
Copy link
Member

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.

@jsuchal
Copy link
Author

jsuchal commented Sep 9, 2010

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.

@jsuchal
Copy link
Author

jsuchal commented Sep 9, 2010

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?

@jzaefferer
Copy link
Member

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.

@jzaefferer
Copy link
Member

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.

@jzaefferer
Copy link
Member

@jsuchal
Copy link
Author

jsuchal commented Sep 9, 2010

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.

@jzaefferer
Copy link
Member

Add, should have clarified that. Was referring to Firefox' addressbar, which got called Awesome Bar when Firefox 3 was released. And it certainly is.

@jsuchal
Copy link
Author

jsuchal commented Sep 9, 2010

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.

@jzaefferer
Copy link
Member

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?

@jsuchal
Copy link
Author

jsuchal commented Sep 9, 2010

I am familiar with unittesting, but not for JS.

@scottgonzalez
Copy link
Member

Implemented in adcafce

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants