aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/dialog/dialog_tickets.js31
-rw-r--r--ui/jquery.ui.dialog.js2
2 files changed, 31 insertions, 2 deletions
diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js
index 1cfdcefea..e65f939e0 100644
--- a/tests/unit/dialog/dialog_tickets.js
+++ b/tests/unit/dialog/dialog_tickets.js
@@ -3,7 +3,36 @@
*/
(function($) {
-module("dialog: tickets");
+module( "dialog: tickets" );
+
+asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
+ expect( 3 );
+
+ var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }),
+ inputs = el.find( "input" ),
+ widget = el.dialog( "widget" );
+
+ inputs.eq( 1 ).focus();
+ equal( document.activeElement, inputs[1], "Focus set on second input" );
+ inputs.eq( 1 ).simulate( "keyup", { keyCode: $.ui.keyCode.TAB });
+
+ setTimeout( checkTab, 2 );
+
+ function checkTab() {
+ ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
+
+ // check shift tab
+ $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
+ setTimeout( checkShiftTab, 2 );
+ }
+
+ function checkShiftTab() {
+ ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
+
+ el.remove();
+ start();
+ }
+});
test("#4826: setting resizable false toggles resizable on dialog", function() {
expect(6);
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index 493ed07e6..e8107db7c 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -293,7 +293,7 @@ $.widget("ui.dialog", {
// prevent tabbing out of modal dialogs
if ( options.modal ) {
- uiDialog.bind( "keypress.ui-dialog", function( event ) {
+ uiDialog.bind( "keyup.ui-dialog", function( event ) {
if ( event.keyCode !== $.ui.keyCode.TAB ) {
return;
}