How to close Office dialog without explicit reference?

Jan Kubica 0 Reputation points
2024-06-22T15:56:06.53+00:00

We are using the Office Dialog API to display the login and logout dialog of our auth provider. Because of the limitation that only one popup can be opened at a time, we want to programmatically close the logout popup if the user wants to login and a logout popup is still open. We tried to just save the asyncResult.value of the callback function of the displayDialogAsync method in a variable (We're using React so we tried to save it in context to be precise) and call its close() method. The problem now is, that if some page reload happens (which does happen in our logout process) the variable (React context in our case) will lose the reference to the dialog, but in the Desktop Version of Office the dialog itself stays open and connected to our plugin. In Office for the web it's not a problem since after reload of the plugin the dialog will be either gone or not detected by the plugin anymore.

TL;DR: We need some sort of 'global dialog close' method (or a workaround for it) that will close the current active dialog if there is one, without the need to keep a reference to the dialog.

Office
Office
A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.
1,428 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,671 questions
0 comments No comments
{count} votes