Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Close and reset a modal

Issue

I'm experiencing a bug where users can press escape to close a modal, despite having quick dismiss disabled. Additionally, when using the function 'helpers.closeShipmentModal()', the modal does not close when the closeModal function is called before the resetWidget function, but it does close when the order is reversed. I've tried using async/await, but it didn't fix the issue. I'm considering dropping the resetWidget from the function and placing it on the On Close event, but it's confusing why the original function doesn't work. I've opened a GitHub issue to address these problems.

Resolution

The issue reported is that a modal is not closing properly when calling the closeModal() function before the resetWidget() function. The recommended solution is to mark the function as async and await both functions, like this:

closeShipmentModal: async () => {
await closeModal('newShipmentModal');
await resetWidget("newShipmentModal", true);
}

Additionally, the user reported an issue with the escape key closing the modal even when quick dismiss is disabled. The suggestion is to bind the escape key to a button to give the designer control over its functionality, or to tie it to quick dismiss. A GitHub issue was created to track this feedback.