OfficeDev / office-js-docs-pr

Microsoft Office Add-ins Documentation
https://learn.microsoft.com/office/dev/add-ins
Creative Commons Attribution 4.0 International
403 stars 248 forks source link

Incorrect example #4870

Open yinhx3 opened 4 days ago

yinhx3 commented 4 days ago

https://learn.microsoft.com/en-us/office/dev/add-ins/develop/dialog-api-in-office-add-ins#cross-domain-messaging-to-the-dialog-runtime

function onMessageFromParent(arg) {
    if (arg.origin === "https://addin.fabrikam.com") {
        // process message
    } else {
        dialog.close();
        showNotification("Messages from " + arg.origin + " aren't accepted.");
    }
}

dialog.close(); can't run in a dialog. Should post message to the host to close a dialog corroding to the section below

AlexJerabek commented 4 days ago

Thanks for reporting this @yinhx3.

@samantharamon, could you please investigate?