@@ -81,6 +81,7 @@ return $.widget( "ui.menu", {
81
81
} ,
82
82
"click .ui-menu-item" : function ( event ) {
83
83
var target = $ ( event . target ) ;
84
+ var active = $ ( $ . ui . safeActiveElement ( this . document [ 0 ] ) ) ;
84
85
if ( ! this . mouseHandled && target . not ( ".ui-state-disabled" ) . length ) {
85
86
this . select ( event ) ;
86
87
@@ -89,10 +90,13 @@ return $.widget( "ui.menu", {
89
90
this . mouseHandled = true ;
90
91
}
91
92
93
+
94
+
92
95
// Open submenu on click
93
96
if ( target . has ( ".ui-menu" ) . length ) {
94
97
this . expand ( event ) ;
95
- } else if ( ! this . element . is ( ":focus" ) && $ ( $ . ui . safeActiveElement ( this . document [ 0 ] ) ) . closest ( ".ui-menu" ) . length ) {
98
+ } else if ( ! this . element . is ( ":focus" ) &&
99
+ active . closest ( ".ui-menu" ) . length ) {
96
100
97
101
// Redirect focus to the menu
98
102
this . element . trigger ( "focus" , [ true ] ) ;
@@ -142,7 +146,11 @@ return $.widget( "ui.menu", {
142
146
} ,
143
147
blur : function ( event ) {
144
148
this . _delay ( function ( ) {
145
- if ( ! $ . contains ( this . element [ 0 ] , $ . ui . safeActiveElement ( this . document [ 0 ] ) ) ) {
149
+ var notContained = ! $ . contains (
150
+ this . element [ 0 ] ,
151
+ $ . ui . safeActiveElement ( this . document [ 0 ] )
152
+ ) ;
153
+ if ( notContained ) {
146
154
this . collapseAll ( event ) ;
147
155
}
148
156
} ) ;
@@ -479,7 +487,8 @@ return $.widget( "ui.menu", {
479
487
var currentMenu = all ? this . element :
480
488
$ ( event && event . target ) . closest ( this . element . find ( ".ui-menu" ) ) ;
481
489
482
- // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
490
+ // If we found no valid submenu ancestor, use the main menu to close all
491
+ // sub menus anyway
483
492
if ( ! currentMenu . length ) {
484
493
currentMenu = this . element ;
485
494
}
0 commit comments