Showing a Modal Dialog
Dialogs are shown using the HTMLDialogElement#showModal
method. This method will render the dialog. The method will return a Promise
, which you can use to easily wait for the dialog to be dismissed.
dialog.showModal()
.then(result => {
// handle dialog result
// if canceled by ESC, will be "reasonCanceled"
});
It's important to note that you can only show one dialog at once. You should always close or dismiss a dialog first and then wait for the dialog's promise to resolve before showing another one.