mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Menu: Handle clicking on a menu item without hovering it first. Fixes #7085 - Menu click when no mouseover causes error.
This commit is contained in:
parent
9b3badea6c
commit
da67ece506
9
ui/jquery.ui.menu.js
vendored
9
ui/jquery.ui.menu.js
vendored
@ -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 ) {
|
||||
@ -102,7 +107,7 @@ $.widget("ui.menu", {
|
||||
event.preventDefault();
|
||||
break;
|
||||
case $.ui.keyCode.ENTER:
|
||||
self.select();
|
||||
self.select( event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user