Skip to content

Commit

Permalink
Menu: Handle clicking on a menu item without hovering it first. Fixes…
Browse files Browse the repository at this point in the history
… #7085 - Menu click when no mouseover causes error.
  • Loading branch information
scottgonzalez committed Mar 15, 2011
1 parent 9b3bade commit da67ece
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ui/jquery.ui.menu.js
Expand Up @@ -34,14 +34,19 @@ $.widget("ui.menu", {
role: "listbox"
})
.bind( "click.menu", function( event ) {
var item = $( event.target ).closest( ".ui-menu-item:has(a)" );
if ( self.options.disabled ) {
return false;
}
if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
if ( !item.length ) {
return;
}
// temporary
event.preventDefault();
// it's possible to click an item without hovering it (#7085)
if ( !self.active || ( self.active[ 0 ] !== item[ 0 ] ) ) {
self.focus( event, item );
}
self.select( event );
})
.bind( "mouseover.menu", function( event ) {
Expand Down Expand Up @@ -102,7 +107,7 @@ $.widget("ui.menu", {
event.preventDefault();
break;
case $.ui.keyCode.ENTER:
self.select();
self.select( event );
event.preventDefault();
event.stopImmediatePropagation();
break;
Expand Down

0 comments on commit da67ece

Please sign in to comment.