t4t5/sweetalert
Tab key not working after opening two Sweet Alert Modals in a row
开放
#127 创建于 2014年10月15日
help wanted
仓库指标
- 星标
- (22,338 个星标)
- PR 合并指标
- (PR 指标待抓取)
描述
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?