t4t5/sweetalert

Tab key not working after opening two Sweet Alert Modals in a row

Open

#127 opened on 2014年10月15日

GitHub で見る
 (21 comments) (4 reactions) (0 assignees)TypeScript (22,338 stars) (2,946 forks)batch import
help wanted

説明

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?

コントリビューターガイド