@@ -40,16 +40,6 @@ $.widget( "ui.menu", {
4040 id : this . menuId ,
4141 role : "menu"
4242 } )
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- } )
5343 // need to catch all clicks on disabled menu
5444 // not possible through _bind
5545 . bind ( "click.menu" , $ . proxy ( function ( event ) {
@@ -58,6 +48,11 @@ $.widget( "ui.menu", {
5848 }
5949 } , this ) ) ;
6050 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+ } ,
6156 "click .ui-menu-item:has(a)" : function ( event ) {
6257 event . stopImmediatePropagation ( ) ;
6358 var target = $ ( event . currentTarget ) ;
@@ -66,6 +61,8 @@ $.widget( "ui.menu", {
6661 this . focus ( event , target ) ;
6762 }
6863 this . select ( event ) ;
64+ // Redirect focus to the menu.
65+ this . element . focus ( ) ;
6966 } ,
7067 "mouseover .ui-menu-item" : function ( event ) {
7168 event . stopImmediatePropagation ( ) ;
0 commit comments