Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#7423 closed bug (fixed)

Tab out of autocomplete with remote source can leave menu showing.

Reported by: sp Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.autocomplete Version: 1.8.13
Keywords: Cc:
Blocked by: Blocking:

Description

This is reproducible using the remote data source example at: http://jqueryui.com/demos/autocomplete/remote.html

Steps to reproduce: 1) Go to example above. 2) Enter 'ro' into field. 3) At the moment you see the spinner, press the tab key

Result:

If you time it just right, you will see the menu pop up, but the focus will be somewhere else. Depending on the browser, it could be on the result field, or on the url in the browser window. This can lead to very strange behavior. If you have two autocompletes side-by-side, and you tab to the second one at the right moment, both will be showing their menus at the same time, with focus on the second field. The slower the data source, the more likely this will happen.

Expected: A check to make sure the field still has focus before showing the menu.

Reproduced in Safari and FireFox on Mac.

Change History (10)

comment:2 Changed 8 years ago by Scott González

Status: newopen

comment:3 Changed 8 years ago by sp

New fix at https://github.com/spekary/jquery-ui/commit/f010015eb9b2c0aaa23f00098c78956db1f0b414. Previous fix broke the external search function.

comment:4 Changed 8 years ago by sp

OK, this is giving me fits. Is there a proper place to have a forum to discuss this solution?

The problem is that you have the possibility of two asynchronous events returning at different times, each effecting the other. As I have been thinking about it, I actually think my first post is the correct solution, because I also think that the correct thing to do is force the field to have the focus if .autocomplete( "search" ) is called. If it doesn't have the focus, then you can still get the possibility of two menus showing up simultaneously, since the menu will not get a blur event if it doesn't have the focus. To prevent the two menu problem, the user of autocomplete must either make sure he focuses the field before the search, or make sure to manually blur the menu when some other event happens.

A test case is difficult to post, because it relies on a slow json call, and jsFiddle and jsbin don't seem to play nice with json easily.

comment:5 in reply to:  4 Changed 8 years ago by rdworth

Replying to sp:

OK, this is giving me fits. Is there a proper place to have a forum to discuss this solution?

Yup. http://forum.jquery.com/developing-jquery-ui and/or #jqueryui-dev on freenode (irc)

comment:6 Changed 8 years ago by sp

Conversation started at http://forum.jquery.com/topic/trying-to-fix-autocomplete-double-menu-problem. Do we fix just this problem, or the related problem caused by an external search? Both can cause two menus to appear. See the test code there.

comment:8 Changed 8 years ago by sp

Checked in unit test for fix.

comment:9 Changed 7 years ago by Shannon

Resolution: fixed
Status: openclosed

Autocomplete: Making sure we do not show search menu after a blur. Fixed #7423 - Tab out of autocomplete with remote source can leave menu showing.

Changeset: 2445e20a856192179590c0d08e5d73479df1e52d

comment:10 Changed 7 years ago by Scott González

#7936 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.