Then the modal hangs for a bit while it resets, then it closes.
I imagine one way of tackling this is dropping the resetWidget from the function and just placing that on the ‘On Close’ event, but it doesn’t make sense why the first way of writing the function (close, then reset) doesn’t work. I even tried using async/await and that didn’t fix it.
This is the expected behavior. Can you elaborate a bit on this issue? If you want to execute an action when the modal is closed, you can run it in the onClose event of the modal. This way it gets triggered even if the user presses ESC.
We want to control the user experience and not have a user accidentally close a modal when they do not intend to. As such we have specific buttons set up to close the modal and always disable quick dismiss.
If the modal is dismissed prematurely that could result in loss of data when the modal requires the user to input data and that data is not submitted. However incomplete sets of data cannot be submitted, so we cannot save the data to the database on close.
Additionally the modal is contextual based on which button the user presses to show it. For example, we could have 5 orders in a table or a list, and each order has a button to create a shipment. The button pops the same modal, but the modal is populated with data related to the row/list item that it is triggered from.
Pressing escape to close the modal could be done on accident while the user is filling the modal with data (just as clicking outside the modal is an easy mistake to make).
Binding escape to a button makes sense, because then the designer can decide if escape should bind to close modal or some other function.
Barring that, escape should be tied to quick dismiss, so the designer can decide if an easy dismissal is desired (escape or clicking outside) or if they need to make sure the user follows the correct workflow to exit safely.