A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
Provide required information needed to triage your issue
Dialogs opened using displayDialogAsync are unable to communicate back to the main add-in using a BroadcastChannel for Office Online.
Your Environment
Platform [PC desktop, Mac, iOS, Office on the web]: Office on the web
Host [Excel, Word, PowerPoint, etc.]: Excel
Operating System: Mac
Browser (if using Office on the web): Chrome
Expected behavior
Create a BroadcastChannel in Excel add-in and register a channel.onmessage listener.
Open a dialog using Office.context.ui.displayDialogAsync(url, { promptBeforeOpen: false }) to a page in the same origin as the add-in (a requirement of displayDialogAsync).
Create a BroadcastChannel in the new dialog window with the same channel id that the add-in's broadcast listener has.
Call channel.postMessage(msg) from the dialog.
The add-in receives the message via the broadcast channel.
Current behavior
The message is never received.
Note that the message is received when run in Excel for Mac. I have also verified that BroadcastChannel works
Steps to reproduce
See Expected behavior section
Link to live example(s)
Provide additional details
A simple dialog page that should be able to communicate back with the add-in
Communicating using BroadcastChannel seems pointless given that Office.context.ui.messageParent exists. Why not just use that?
I tried that, but after going thru my OAuth redirect flow (cross-origin), it is no longer possible to communicate with the add-in because Office.js cannot be loaded. I suspect this is due to the fact that window.opener is null after all the redirects. See https://github.com/OfficeDev/office-js/issues/3673 (comments at the end) for other users who appear to be having this same issue with Office Online. I suspect that if my OAuth provider set the correct headers, the referrer and/or original window opener could be preserved and things would work, but I do not have control over that.
I wanted a workaround solution, and BroadcastChannel should work as a mechanism for communicating between a window and an iframe from the same origin. However, something about Office Online seems to be blocking the BroadcastChannel communication to and from the add-in.
Useful logs
[ ] Console errors
[ ] Screenshots
[ ] Test file (if only happens on a particular file)
Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.
Provide required information needed to triage your issue
Dialogs opened using displayDialogAsync are unable to communicate back to the main add-in using a BroadcastChannel for Office Online.
Your Environment
Expected behavior
channel.onmessage
listener.Office.context.ui.displayDialogAsync(url, { promptBeforeOpen: false })
to a page in the same origin as the add-in (a requirement of displayDialogAsync).channel.postMessage(msg)
from the dialog.Current behavior
The message is never received. Note that the message is received when run in Excel for Mac. I have also verified that BroadcastChannel works
Steps to reproduce
Link to live example(s)
Provide additional details
Context
Communicating using BroadcastChannel seems pointless given that Office.context.ui.messageParent exists. Why not just use that?
I tried that, but after going thru my OAuth redirect flow (cross-origin), it is no longer possible to communicate with the add-in because Office.js cannot be loaded. I suspect this is due to the fact that window.opener is null after all the redirects. See https://github.com/OfficeDev/office-js/issues/3673 (comments at the end) for other users who appear to be having this same issue with Office Online. I suspect that if my OAuth provider set the correct headers, the referrer and/or original window opener could be preserved and things would work, but I do not have control over that.
I wanted a workaround solution, and BroadcastChannel should work as a mechanism for communicating between a window and an iframe from the same origin. However, something about Office Online seems to be blocking the BroadcastChannel communication to and from the add-in.
Useful logs
Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.