Event handlers for dialogs displayed using Office.context.ui.displayDialogAsync do not capture DialogMessageReceived events after an email has been moved using a Graph move request. After moving an email, the add-in can open another dialog, but events are never captured in the dialog's callback function.
The main branch of this repo reproduces this error in the scenario closest to our actual code, where we use promises to get the dialog result in our main function and then move the email and complete the click event there. The simplified branch of this repo reproduces the issue using displayDialogAsync with a regular callback.
This repo uses Microsoft Graph, so we need an Entra app to get auth tokens.
- In Entra, go to "App registrations" and click "New registration".
- Add a name for the app. Add a redirect URI of type "Single-page application (SPA)":
brk-multihub://localhost:3000. Click "Register". - On the "Overview" page for the new app, write down the "Application (client) ID" and "Directory (tenant) ID" numbers to be added to the local add-in later.
- On the "Authentication" tab, click "Add Redirect URI" and click "Single-page application". Enter the redirect URI
http://localhost:3000/taskpane.htmland click "Configure". - On the "API permissions" tab, click "Add a permission", click "Microsoft Graph", and click "Delegated Permissions". Add the permission
Mail.ReadWrite. - On the same page, click "Grant admin consent for MSFT".
- Log into an email account from the tenant with the app registration from the last section in OWA.
- Go to
aka.ms/olksideload, and in the menu that appears, go to "My add-ins" and click "Add a custom add-in". - Install the manifest file
manifest-localhost.xml. Empty the cache and do a hard reload. - Open an email and open the apps menu. An app with the name "Dialog API Bug Demo" should appear.
- Clone this repo locally and navigate to it in a Terminal or bash shell.
- In the file
taskpane.js, replace[APPLICATION ID]and[TENANT ID]with the application and tenant IDs from the app registration. - Run the command
npm install. - Run the command
npm start.- From the Microsoft sample add-in used as the basis for this one: If you've never developed an Office add-in on this computer before or it has been more than 30 days since you last did, you'll be prompted to delete an old security certificate and/or install a new one. Agree to both prompts.
- Open an email and open the apps menu. Click the "Dialog API Bug Demo" button. A dialog with two buttons (one to delete an email and one to cancel) should appear.
- Click the button to delete the email and wait for the email to be deleted.
- Open a different email, open the apps menu, and click the "Dialog API Bug Demo" button.
- On the new dialog, click either button. The dialog does not respond and the email is not deleted.
This repo was created using these two repos: