-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BootstrapDialog.moveFocus may be move focus to a none visible dialog! #224
Labels
Comments
Please fork this jsfiddle http://jsfiddle.net/3c03mckb/1/ and create a live demo to reproduce the bug, thank you. |
try this code! <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.9/css/bootstrap-dialog.css" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.9/js/bootstrap-dialog.js"></script>
<input type="button" value="btn1" id="mytestbtn1"/>
var dlg1 = new BootstrapDialog({
title: 'dialog1',
message: 'press esc will can not close dialog1? because focus is in invisible dialog! try press tab key',
autodestroy: false,
buttons: [{
label: 'cancel',
action: function (dialog) {
return dialog.close();
}
}]
});
var dlg2 = new BootstrapDialog({
title: 'dialog2',
message: 'try press esc to find where is the focus?',
autodestroy: false,
buttons: [{
label: 'cancel',
action: function (dialog) {
return dialog.close();
}
}]
});
var dlg3 = new BootstrapDialog({
title: 'dialog3',
message: 'press esc.',
autodestroy: false,
buttons: [{
label: 'cancel',
action: function (dialog) {
return dialog.close();
}
}]
});
$('#mytestbtn1').click(function() {
dlg1.open();
dlg2.open();
dlg3.open();
}); |
This code can fix it? /**
* Move focus to next visible dialog.
*/
BootstrapDialog.moveFocus = function () {
var lastDialogInstance = null;
var topVisibleDialogZIndex = getTopVisibleDialogZIndex(); // @todo: try to implement.
$.each(BootstrapDialog.dialogs, function (id, dialogInstance) {
if( dialogInstance.opened && topVisibleDialogZIndex == dialogInstance.$modal.css('zIndex') ) {
lastDialogInstance = dialogInstance;
}
});
if (lastDialogInstance !== null && lastDialogInstance.isRealized()) {
lastDialogInstance.getModal().focus();
}
}; |
Thank you, looking into it. |
Patched, please see this commit. 185087c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Open dialog_a -> dialog_b -> dialog_c , then press ESC will see the bug.
The text was updated successfully, but these errors were encountered: