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 () {
27
27
// Item roles are tested in the role option tests
28
28
} ) ;
29
29
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
+
30
48
} ) ( jQuery ) ;
Original file line number Diff line number Diff line change @@ -85,7 +85,8 @@ $.widget( "ui.menu", {
85
85
// Open submenu on click
86
86
if ( target . has ( ".ui-menu" ) . length ) {
87
87
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
+
89
90
// Redirect focus to the menu
90
91
this . element . trigger ( "focus" , [ true ] ) ;
91
92
You can’t perform that action at this time.
0 commit comments