t4t5 / sweetalert

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

Alert with type "input" moves into promise and doesn't actually wait for input when launched by enter key, does when clicked #760

Open ATChustz opened 6 years ago

ATChustz commented 6 years ago

I'm using an input SweetAlert to password-protect certain user settings. These settings live on a page with a multiple forms and multiple "save" buttons. Users enter their password into the alert that is launched by hitting any of the settings page's save buttons and then, if the password is correct, their settings update to reflect what they have changed on the page.

For some reason, the sweetalert performs as expected when the "save" buttons are clicked, but not when enter is hit in the form fields. When enter is hit in a form field, the modal behaves as if the confirm button has already been pressed and my debugger shows that I am already in the promise that specifies what to do after the confirm button is pressed

This exact functionality worked just fine in sweetalert 1.x. I'm in the process up updating our sweetalerts from 1.x to 2.x, and this is the only thing keeping me from finishing this upgrade. Adding a 100ms timeout around the sweetalert solves this problem, but that feels hacky. What can I do to stop this from happening?

t4t5 commented 6 years ago

Could you provide a jsfiddle or a code example to make this easier to test?