No event is fired when closing a dialog via ESC

2020-07-27 07:43发布

问题:

This issue is occurring using Outlook Web App on OSX. It has been replicated using Chrome, Firefox, and Safari.

Scenario

UI.displayDialogAsync() is used with the displayInIframe: true option.

If a user hits the ESC key, the dialog will close but not trigger Office.EventType.DialogEventReceived.

On top of this, the same dialog can not be opened again (probably because somewhere an opened flag is still set to true or something).


Expected Behavior

The dialog closes and emits an event with error 12006 (dialog closed by user).


Current Behavior

The dialog closes, and does not emit anything and dialog cannot be reopened.


Code

All our OfficeJs related calls are wrapped inside a service, and inside that service we have an openDialog method that wraps ui.displayDialogAsync:

public openDialog(dialog: string, width: number, height: number, displayInIframe: boolean = true) : Promise < Office.DialogHandler > {
    return new Promise((resolve, reject) => {
        this.ui.displayDialogAsync(`https://${OWA_HOST}/${dialog}`, { width, height, displayInIframe }, (result) => {
            //... error handling + reject(result.value)
            resolve(result.value)
        });
    });
}

openDialog is then used somwhere else in our Angular app:

this.owaService.openDialog('dialog-access-rights.html', 60, 50, true)
    .then((handler: Office.DialogHandler) => {
        this.handler = handler;
        handler.addEventHandler(Office.EventType.DialogMessageReceived, this.messageHandler.bind(this));
        handler.addEventHandler(Office.EventType.DialogEventReceived, this.eventHandler.bind(this));
    })
    .catch(error => {
        this.log.error('Error opening AR dialog', {
            error
        });
    });

error returned by Office :


I've posted this in the Office.js CDN/NPM GitHub as well.

This issue: OWA: Dialog API support is similar, though I've left my question as-is since it is a more barebone description of the same bug.