vue-final / vue-final-modal

🍕Vue Final Modal is a tiny, renderless, mobile-friendly, feature-rich modal component for Vue.js.
https://vue-final-modal.org
MIT License
930 stars 99 forks source link

How do I prevent a dynamic modal closing using an async onBeforeClose? #458

Open beard7 opened 1 week ago

beard7 commented 1 week ago

I using UseModal() to create a dynamic modals with edit forms for a data grid. It's working really well, but I've hit a snag.

I need to display a warning before closing the modal if the form has changed (and is not being saved). The warning uses an async method to await for user confirmation, so I'm trying this:

...
onBeforeClose: async (ev) => { 
    const close = await beforeEditModalClose();
    if (!close) {
        ev.stop();
    }
}
...

the modal is closing before I've got the result from beforeEditModalClose()

Any suggeestions? Thanks