t4t5/sweetalert

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

Offen

#127 geöffnet am 15.10.2014

 (21 Kommentare) (4 Reaktionen) (0 zugewiesene Personen)TypeScript (2.946 Forks)batch import
help wanted

Repository-Metriken

Stars
 (22.338 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

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?

Contributor Guide