mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Dialog: Fix shift-tab handling, focus the correct element
Copy-paste error introduced in df6110c0d4
Updates the tabbing test to be more specific about which element should
have focus, instead of only checking if focus is within the dialog.
Ref #9646
Ref #10103
Closes gh-1264
This commit is contained in:
parent
c31d5f0688
commit
a0b84767a7
@ -140,12 +140,14 @@ test( "#7960: resizable handles below modal overlays", function() {
|
|||||||
asyncTest( "Prevent tabbing out of dialogs", function() {
|
asyncTest( "Prevent tabbing out of dialogs", function() {
|
||||||
expect( 3 );
|
expect( 3 );
|
||||||
|
|
||||||
var element = $( "<div><input><input></div>" ).dialog(),
|
var element = $( "<div><input name='0'><input name='1'></div>" ).dialog(),
|
||||||
inputs = element.find( "input" ),
|
inputs = element.find( "input" );
|
||||||
widget = element.dialog( "widget" )[ 0 ];
|
|
||||||
|
// Remove close button to test focus on just the two buttons
|
||||||
|
element.dialog( "widget" ).find( ".ui-button").remove();
|
||||||
|
|
||||||
function checkTab() {
|
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
|
// check shift tab
|
||||||
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
|
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
|
||||||
@ -153,7 +155,7 @@ asyncTest( "Prevent tabbing out of dialogs", function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkShiftTab() {
|
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();
|
element.remove();
|
||||||
setTimeout( start );
|
setTimeout( start );
|
||||||
|
@ -348,7 +348,7 @@ return $.widget( "ui.dialog", {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
|
} else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
|
||||||
this._delay(function() {
|
this._delay(function() {
|
||||||
first.focus();
|
last.focus();
|
||||||
});
|
});
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user