aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-03-15 14:02:18 -0400
committerScott González <scott.gonzalez@gmail.com>2011-03-15 14:02:18 -0400
commitda67ece506ab69ef2d6d6bc6c1cf60be48776d4c (patch)
treedd5e08ca1f32f13da91c6d3c876d8b8a1d9ca692 /ui
parent9b3badea6cce68e5b93a18d54e0eb836b3c3b406 (diff)
downloadjquery-ui-da67ece506ab69ef2d6d6bc6c1cf60be48776d4c.tar.gz
jquery-ui-da67ece506ab69ef2d6d6bc6c1cf60be48776d4c.zip
Menu: Handle clicking on a menu item without hovering it first. Fixes #7085 - Menu click when no mouseover causes error.
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.menu.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index cd07b6418..2addba37e 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -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;