t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.4k stars 2.84k forks source link

SweetAlert2 popup instantly closes on IE11 on keypress #946

Open Aarthi-Saba opened 3 years ago

Aarthi-Saba commented 3 years ago

I have used Sweetalert2 inside a form to display popup . Below are the urls used for cdn and the IE polyfills

below is the Swal code I have used for my popup.

function popup(){
Swal.fire({
               html: "<div class='swal-custom-text'><span id='mypopup' tabindex='-1' role='dialog' aria-labelledby='mypopup'>heading</span> <br><br> <span> My text</span></div>",
               confirmButtonText: 'OK',
               didOpen: focusdialog
                 })
                    .then(function () {
                        document.getElementById('test').focus();
                    });
}
<div role="button" id="test" tabindex="0" style="color: red; cursor: pointer" title="<%= covidinfo  %>" onkeypress="popup();"    onclick="popup();" value="<% =info  %>" />

Onclick function opens swal as expected,but onkeypress just flashes popup for a second and autocloses on IE11 This works fine on other browsers like chrome,firefox,safari and edge.