t4t5/sweetalert
View on GitHubTab key not working after opening two Sweet Alert Modals in a row
Open
#127 opened on Oct 15, 2014
help wanted
Description
Hello,
It seems that when the SweetAlert dialog opens another one after it's done, the tab key stops working, all other keystrokes are okay.
You can recreate this using the example on http://tristanedwards.me/sweetalert.
This one specifically:
swal({ title: "Are you sure?",
text: "Your will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false },
function(isConfirm){
if (isConfirm) {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
} });
I believe it's copying over the keystroke handling from the previous modal, specifically in the closeModal() function, this part:
// Reset the page to its previous state
window.onkeydown = previousWindowKeyDown;
document.onclick = previousDocumentClick;
if (previousActiveElement) {
previousActiveElement.focus();
}
Perhaps it's simply focusing on the previous modal and registering back it's keydown and onclick?