File tree 2 files changed +26
-3
lines changed
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ test("widget method", function() {
41
41
} ) ;
42
42
43
43
asyncTest ( "focus tabbable" , function ( ) {
44
- expect ( 6 ) ;
44
+ expect ( 8 ) ;
45
45
var element ,
46
46
options = {
47
47
buttons : [ {
@@ -118,7 +118,30 @@ asyncTest( "focus tabbable", function() {
118
118
setTimeout ( function ( ) {
119
119
equal ( document . activeElement , element . parent ( ) [ 0 ] , "6. the dialog itself" ) ;
120
120
element . remove ( ) ;
121
- start ( ) ;
121
+ setTimeout ( step7 ) ;
122
+ } ) ;
123
+ }
124
+
125
+ function step7 ( ) {
126
+ element = $ ( "<div><input name='0'><input name='1' autofocus></div>" ) . dialog ( {
127
+ open : function ( ) {
128
+ var inputs = $ ( this ) . find ( "input" ) ;
129
+ inputs . last ( ) . keydown ( function ( event ) {
130
+ event . preventDefault ( ) ;
131
+ inputs . first ( ) . focus ( ) ;
132
+ } ) ;
133
+ }
134
+ } ) ;
135
+ setTimeout ( function ( ) {
136
+ var inputs = element . find ( "input" ) ;
137
+ equal ( document . activeElement , inputs [ 1 ] , "Focus starts on second input" ) ;
138
+ inputs . last ( ) . simulate ( "keydown" , { keyCode : $ . ui . keyCode . TAB } ) ;
139
+ setTimeout ( function ( ) {
140
+ equal ( document . activeElement , inputs [ 0 ] ,
141
+ "Honor preventDefault, allowing custom focus management" ) ;
142
+ element . remove ( ) ;
143
+ start ( ) ;
144
+ } , 50 ) ;
122
145
} ) ;
123
146
}
124
147
Original file line number Diff line number Diff line change @@ -334,7 +334,7 @@ return $.widget( "ui.dialog", {
334
334
}
335
335
336
336
// prevent tabbing out of dialogs
337
- if ( event . keyCode !== $ . ui . keyCode . TAB ) {
337
+ if ( event . keyCode !== $ . ui . keyCode . TAB || event . isDefaultPrevented ( ) ) {
338
338
return ;
339
339
}
340
340
var tabbables = this . uiDialog . find ( ":tabbable" ) ,
You can’t perform that action at this time.
0 commit comments