Ticket #7085 (closed bug: fixed)
Menu click when no mouseover causes error
| Reported by: | scott.moore | Owned by: | scott.moore |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.9.0 |
| Component: | ui.autocomplete | Version: | 1.8.10 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
If you use autocomplete, and have your mouse already in position over where the menu will appear and click without moving it you get an error. Basically trigger the click without triggering the mousover.
The select method in the menu code (jquery.ui.menu.js line 368) does not check that an active item exists and this causes an error in the autocomplete code (jquery.ui.autocomplete.js line 180) when it assumes an item. There are a couple fixes, one is to make the autocomplete code not assume an item and fail gracefully, and the other is to make the menu select the menu item that was clicked if it has no active item. Here is what that might look like if you replaced the menu's select method:
select: function(event) {
if (!this.active) {
this.active = $(event.target).closest(".ui-menu-item");
}
// save active reference before closeAll triggers blur
var ui = {
item: this.active
};
this.closeAll();
this._trigger("select", event, ui);
}
This is against the latest version of the code, and that initial if block is the only new part. It works just as well in the latest released version (1.8.10)
Change History
comment:1 Changed 2 years ago by joern.zaefferer
- Owner set to scott.moore
- Status changed from new to pending
comment:2 Changed 2 years ago by t34
Same problem here with ff3.6.15 or IE8 on w7
How to reproduce:
- open http://jqueryui.com/demos/autocomplete/combobox.html
- set the cursor to the edit field
- press an holt key_up (menu is shown and the entry scrolls continuously)
- click some times at the first entry
- open the error console (ff) or double click at the error icon (IE)
comment:4 Changed 2 years ago by Scott González
- Status changed from open to closed
- Resolution set to fixed
Menu: Handle clicking on a menu item without hovering it first. Fixes #7085 - Menu click when no mouseover causes error.
Changeset: da67ece506ab69ef2d6d6bc6c1cf60be48776d4c


The suggested patch looks good, but I'd like to reproduce this in order to write a test, too. I tried reproducing on OSX/Chrome, XP/IE6 and Win7/Chrome. In each case the item gets activated on click.
What system/browser are you testing?