Skip to content
Browse files

Create mouseHandled flag per instance instead of globally. Fixes #886…

…6 - Menu: select event not firing due to mouseHandled flag reset bug
  • Loading branch information...
1 parent 2c3d311 commit 5143b7f672bc668963cce7dcf5dd4e2970aad8e5 @kborchers kborchers committed Dec 27, 2012
Showing with 4 additions and 5 deletions.
  1. +4 −5 ui/jquery.ui.menu.js
View
9 ui/jquery.ui.menu.js
@@ -15,8 +15,6 @@
*/
(function( $, undefined ) {
-var mouseHandled = false;
-
$.widget( "ui.menu", {
version: "@VERSION",
defaultElement: "<ul>",
@@ -40,6 +38,7 @@ $.widget( "ui.menu", {
_create: function() {
this.activeMenu = this.element;
+ this.mouseHandled = false;
this.element
.uniqueId()
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
@@ -73,8 +72,8 @@ $.widget( "ui.menu", {
},
"click .ui-menu-item:has(a)": function( event ) {
var target = $( event.target ).closest( ".ui-menu-item" );
- if ( !mouseHandled && target.not( ".ui-state-disabled" ).length ) {
- mouseHandled = true;
+ if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
+ this.mouseHandled = true;
this.select( event );
// Open submenu on click
@@ -130,7 +129,7 @@ $.widget( "ui.menu", {
}
// Reset the mouseHandled flag
- mouseHandled = false;
+ this.mouseHandled = false;
}
});
},

5 comments on commit 5143b7f

@jzaefferer
jQuery Foundation member

Thanks. Could you also add a comment or two to document why this is needed?

@fnagel
jQuery Foundation member
fnagel commented on 5143b7f Jan 10, 2013

I think this could be useful for this issue too: http://bugs.jqueryui.com/ticket/8929

@jzaefferer
jQuery Foundation member

@fnagel it landed in master - could you merge and test with selectmenu?

@fnagel
jQuery Foundation member
fnagel commented on 5143b7f Jan 11, 2013

@jzaefferer Perhaps its possible to remove the custom delay and use the flas var directly. I will give it a try this weekend!

@fnagel
jQuery Foundation member
fnagel commented on 5143b7f Jan 11, 2013

@jzaefferer No, that did not work. Without changing the delay for the blur method the class on the active item will always be removed. We would need a way to handle the focus within Selectmenu.

Please sign in to comment.
Something went wrong with that request. Please try again.