aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorkborchers <kris.borchers@gmail.com>2012-07-12 22:45:56 -0500
committerkborchers <kris.borchers@gmail.com>2012-07-12 22:45:56 -0500
commitb8ad711deedab11da1f181b486ee67f259a3ef7c (patch)
tree07afd8bdb2a5042e00d1980e6e66f038fdeea7b9 /ui
parente054e28836e616ed03561d5a8195bbea525866d1 (diff)
downloadjquery-ui-b8ad711deedab11da1f181b486ee67f259a3ef7c.tar.gz
jquery-ui-b8ad711deedab11da1f181b486ee67f259a3ef7c.zip
Menu: Add a flag and remove previous attempt to prevent select events from being fired by click events bubbling up through nested menus
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.menu.js36
1 files changed, 14 insertions, 22 deletions
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 81fef2e7c..e8b8ed1fc 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -15,7 +15,7 @@
*/
(function( $, undefined ) {
-var currentEventTarget = null;
+var mouseHandled = false;
$.widget( "ui.menu", {
version: "@VERSION",
@@ -73,24 +73,16 @@ $.widget( "ui.menu", {
},
"click .ui-menu-item:has(a)": function( event ) {
var target = $( event.target );
- if ( target[0] !== currentEventTarget ) {
- currentEventTarget = target[0];
- // TODO: What are we trying to accomplish with this check?
- // Clicking a menu item twice results in a select event with
- // an empty ui.item.
- target.one( "click" + this.eventNamespace, function( event ) {
- currentEventTarget = null;
- });
- // Don't select disabled menu items
- if ( !target.closest( ".ui-menu-item" ).is( ".ui-state-disabled" ) ) {
- this.select( event );
- // Redirect focus to the menu with a delay for firefox
- this._delay(function() {
- if ( !this.element.is(":focus") ) {
- this.element.focus();
- }
- }, 20 );
- }
+ if ( !mouseHandled && target.closest( ".ui-menu-item" ).not( ".ui-state-disabled" ).length ) {
+ mouseHandled = true;
+
+ this.select( event );
+ // Redirect focus to the menu with a delay for firefox
+ this._delay(function() {
+ if ( !this.element.is(":focus") ) {
+ this.element.focus();
+ }
+ }, 20 );
}
},
"mouseenter .ui-menu-item": function( event ) {
@@ -127,6 +119,9 @@ $.widget( "ui.menu", {
if ( !$( event.target ).closest( ".ui-menu" ).length ) {
this.collapseAll( event );
}
+
+ // Reset the mouseHandled flag
+ mouseHandled = false;
}
});
},
@@ -166,9 +161,6 @@ $.widget( "ui.menu", {
// Destroy menu dividers
this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
-
- // Unbind currentEventTarget click event handler
- this._off( $( currentEventTarget ), "click" );
},
_keydown: function( event ) {