diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index c08019da9..c97f9585b 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -140,12 +140,14 @@ test( "#7960: resizable handles below modal overlays", function() { asyncTest( "Prevent tabbing out of dialogs", function() { expect( 3 ); - var element = $( "
" ).dialog(), - inputs = element.find( "input" ), - widget = element.dialog( "widget" )[ 0 ]; + var element = $( "
" ).dialog(), + inputs = element.find( "input" ); + + // Remove close button to test focus on just the two buttons + element.dialog( "widget" ).find( ".ui-button").remove(); function checkTab() { - ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" ); + equal( document.activeElement, inputs[ 0 ], "Tab key event moved focus within the modal" ); // check shift tab $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true }); @@ -153,15 +155,15 @@ asyncTest( "Prevent tabbing out of dialogs", function() { } function checkShiftTab() { - ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" ); + equal( document.activeElement, inputs[ 1 ], "Shift-Tab key event moved focus back to second input" ); element.remove(); setTimeout( start ); } - inputs[1].focus(); + inputs[ 1 ].focus(); setTimeout(function() { - equal( document.activeElement, inputs[1], "Focus set on second input" ); + equal( document.activeElement, inputs[ 1 ], "Focus set on second input" ); inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB }); setTimeout( checkTab ); diff --git a/ui/dialog.js b/ui/dialog.js index 358000881..7998b042c 100644 --- a/ui/dialog.js +++ b/ui/dialog.js @@ -348,7 +348,7 @@ return $.widget( "ui.dialog", { event.preventDefault(); } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) { this._delay(function() { - first.focus(); + last.focus(); }); event.preventDefault(); }