Opened 12 years ago

Closed 12 years ago

#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:
Blocked by: Blocking:

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 (4)

comment:1 Changed 12 years ago by Jörn Zaefferer

Owner: set to scott.moore
Status: newpending

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?

comment:2 Changed 12 years ago by t34

Same problem here with ff3.6.15 or IE8 on w7

How to reproduce:

comment:3 Changed 12 years ago by Scott González

Status: pendingopen

comment:4 Changed 12 years ago by Scott González

Resolution: fixed
Status: openclosed

Menu: Handle clicking on a menu item without hovering it first. Fixes #7085 - Menu click when no mouseover causes error.

Changeset: da67ece506ab69ef2d6d6bc6c1cf60be48776d4c

Note: See TracTickets for help on using tickets.