File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 3
3
*/
4
4
( function ( $ ) {
5
5
6
- module ( "dialog: tickets" ) ;
6
+ module ( "dialog: tickets" ) ;
7
+
8
+ asyncTest ( "#3123: Prevent tabbing out of modal dialogs" , function ( ) {
9
+ expect ( 3 ) ;
10
+
11
+ var el = $ ( "<div><input id='t3123-first'><input id='t3123-last'></div>" ) . dialog ( { modal : true } ) ,
12
+ inputs = el . find ( "input" ) ,
13
+ widget = el . dialog ( "widget" ) ;
14
+
15
+ inputs . eq ( 1 ) . focus ( ) ;
16
+ equal ( document . activeElement , inputs [ 1 ] , "Focus set on second input" ) ;
17
+ inputs . eq ( 1 ) . simulate ( "keyup" , { keyCode : $ . ui . keyCode . TAB } ) ;
18
+
19
+ setTimeout ( checkTab , 2 ) ;
20
+
21
+ function checkTab ( ) {
22
+ ok ( $ . contains ( widget , document . activeElement ) , "Tab key event moved focus within the modal" ) ;
23
+
24
+ // check shift tab
25
+ $ ( document . activeElement ) . simulate ( "keydown" , { keyCode : $ . ui . keyCode . TAB , shiftKey : true } ) ;
26
+ setTimeout ( checkShiftTab , 2 ) ;
27
+ }
28
+
29
+ function checkShiftTab ( ) {
30
+ ok ( $ . contains ( widget , document . activeElement ) , "Shift-Tab key event moved focus within the modal" ) ;
31
+
32
+ el . remove ( ) ;
33
+ start ( ) ;
34
+ }
35
+ } ) ;
7
36
8
37
test ( "#4826: setting resizable false toggles resizable on dialog" , function ( ) {
9
38
expect ( 6 ) ;
Original file line number Diff line number Diff line change @@ -329,9 +329,9 @@ $.widget("ui.dialog", {
329
329
self . moveToTop ( true ) ;
330
330
331
331
// prevent tabbing out of modal dialogs
332
- if ( options . modal ) {
333
- uiDialog . bind ( 'keypress .ui-dialog' , function ( event ) {
334
- if ( event . keyCode !== $ . ui . keyCode . TAB ) {
332
+ if ( options . modal ) {
333
+ uiDialog . bind ( "keyup .ui-dialog" , function ( event ) {
334
+ if ( event . keyCode !== $ . ui . keyCode . TAB ) {
335
335
return ;
336
336
}
337
337
You can’t perform that action at this time.
0 commit comments