@@ -40,16 +40,6 @@ $.widget( "ui.menu", {
40
40
id : this . menuId ,
41
41
role : "menu"
42
42
} )
43
- // Prevent focus from sticking to links inside menu after clicking
44
- // them (focus should always stay on UL during navigation).
45
- // If the link is clicked, redirect focus to the menu.
46
- // TODO move to _bind below
47
- . bind ( "mousedown.menu" , function ( event ) {
48
- if ( $ ( event . target ) . is ( "a" ) ) {
49
- event . preventDefault ( ) ;
50
- $ ( this ) . focus ( 1 ) ;
51
- }
52
- } )
53
43
// need to catch all clicks on disabled menu
54
44
// not possible through _bind
55
45
. bind ( "click.menu" , $ . proxy ( function ( event ) {
@@ -58,6 +48,11 @@ $.widget( "ui.menu", {
58
48
}
59
49
} , this ) ) ;
60
50
this . _bind ( {
51
+ // Prevent focus from sticking to links inside menu after clicking
52
+ // them (focus should always stay on UL during navigation).
53
+ "mousedown .ui-menu-item > a" : function ( event ) {
54
+ event . preventDefault ( ) ;
55
+ } ,
61
56
"click .ui-menu-item:has(a)" : function ( event ) {
62
57
event . stopImmediatePropagation ( ) ;
63
58
var target = $ ( event . currentTarget ) ;
@@ -66,6 +61,8 @@ $.widget( "ui.menu", {
66
61
this . focus ( event , target ) ;
67
62
}
68
63
this . select ( event ) ;
64
+ // Redirect focus to the menu.
65
+ this . element . focus ( ) ;
69
66
} ,
70
67
"mouseover .ui-menu-item" : function ( event ) {
71
68
event . stopImmediatePropagation ( ) ;
0 commit comments