File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -27,4 +27,22 @@ test( "accessibility", function () {
2727 // Item roles are tested in the role option tests
2828} ) ;
2929
30+ asyncTest ( "#9044: Autofocus issue with dialog opened from menu widget" , function ( ) {
31+ expect ( 1 ) ;
32+ var element = $ ( "#menu1" ) . menu ( ) ;
33+
34+ $ ( "<input>" , { id : "test9044" } ) . appendTo ( "body" ) ;
35+
36+ $ ( "#testID1" ) . bind ( "click" , function ( ) {
37+ $ ( "#test9044" ) . focus ( ) ;
38+ } ) ;
39+
40+ TestHelpers . menu . click ( element , "3" ) ;
41+ setTimeout ( function ( ) {
42+ equal ( document . activeElement . id , "test9044" , "Focus was swallowed by menu" ) ;
43+ $ ( "#test9044" ) . remove ( ) ;
44+ start ( ) ;
45+ } ) ;
46+ } ) ;
47+
3048} ) ( jQuery ) ;
Original file line number Diff line number Diff line change @@ -85,7 +85,8 @@ $.widget( "ui.menu", {
8585 // Open submenu on click
8686 if ( target . has ( ".ui-menu" ) . length ) {
8787 this . expand ( event ) ;
88- } else if ( ! this . element . is ( ":focus" ) ) {
88+ } else if ( ! this . element . is ( ":focus" ) && $ ( this . document [ 0 ] . activeElement ) . closest ( ".ui-menu" ) . length ) {
89+
8990 // Redirect focus to the menu
9091 this . element . trigger ( "focus" , [ true ] ) ;
9192
You can’t perform that action at this time.
0 commit comments