Skip to content

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

Open
@beard7

Description

@beard7

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

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions