OfficeDev / office-js

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.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 96 forks source link

Outlook hangs and OnSend event handler add-in breaks if user switches to a different email while add-in is in progress. #3124

Closed abdumanas-plutoflume closed 5 months ago

abdumanas-plutoflume commented 1 year ago

Message from office-js bot: We’re closing this issue because it has been inactive for a long time. We’re doing this to keep the issues list manageable and useful for everyone. If this issue is still relevant for you, please create a new issue. Thank you for your understanding and continued feedback.

Provide required information needed to triage your issue

When the onSend event handler add-in is in progress, if the user clicks on another email, Outlook hangs and the add-in breaks.

Once user clicks on another email, the Office.js APIs invoked from the add-in starts to fail. Even if the event is released from the addin using the completed method, email is not released. The send button is greyed out and we have to refresh outlook and try again.

Interestingly, the displayDialogAsync seemed to work even when the other APIs failed. So I think only the Office.js APIs related to Office.context.mailbox are failing. Might be because of the change in context.

Outlook for Mac closes the writing pane once email is sent (ideal UX in my opinion) and even if user switches to a different email, the add-in processing isn't affected.

Outlook for windows displays a default alert but the add-in is still shutdown and all progress is lost. So issue exists in OWA and Outlook for windows

I can try to block the user from clicking elsewhere by opening a dialog box, but it could result in other issues like #3097 . And it should be handled gracefully like in either Outlook for Mac.

Your Environment

Expected behavior

The add-in should continue processing even if user switches to a different email, like in Outlook for Mac.

Current behavior

The add-in breaks if user switches to a different email while it's in progress.

Steps to reproduce

  1. Create an onSend event handler add-in

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
    xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
    xsi:type="MailApp">
    <Id>312ccfa2-7b0d-4347-913c-dba690f36ed7</Id>
    <Version>1.0.0.0</Version>
    <ProviderName>Contoso</ProviderName>
    <DefaultLocale>en-US</DefaultLocale>
    <DisplayName DefaultValue="auth-dialogue-issue" />
    <Description DefaultValue="A template to get started." />
    <IconUrl DefaultValue="https://localhost:3000/assets/icon-64.png" />
    <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-128.png" />
    <SupportUrl DefaultValue="https://www.contoso.com/help" />
    <AppDomains>
    <AppDomain>https://www.contoso.com</AppDomain>
    </AppDomains>
    <Hosts>
    <Host Name="Mailbox" />
    </Hosts>
    <Requirements>
    <Sets>
      <Set Name="Mailbox" MinVersion="1.1" />
    </Sets>
    </Requirements>
    <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://localhost:3000/taskpane.html" />
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
    </FormSettings>
    <Permissions>ReadWriteItem</Permissions>
    <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
    </Rule>
    <DisableEntityHighlighting>false</DisableEntityHighlighting>
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides"
    xsi:type="VersionOverridesV1_0">
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1"
      xsi:type="VersionOverridesV1_1">
      <Requirements>
        <bt:Sets DefaultMinVersion="1.3">
          <bt:Set Name="Mailbox" />
        </bt:Sets>
      </Requirements>
      <Hosts>
    
        <Host xsi:type="MailHost">
          <DesktopFormFactor>
            <FunctionFile resid="residUILessFunctionFileUrl" />
            <ExtensionPoint xsi:type="Events">
              <Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="onSendCallback" />
            </ExtensionPoint>
          </DesktopFormFactor>
        </Host>
    
      </Hosts>
      <Resources>
        <bt:Images>
          <bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png" />
          <bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png" />
          <bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png" />
        </bt:Images>
        <bt:Urls>
          <bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html" />
          <bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html" />
          <bt:Url id="residUILessFunctionFileUrl"
            DefaultValue="https://localhost:3000/commands.html"></bt:Url>
        </bt:Urls>
        <bt:ShortStrings>
          <bt:String id="GroupLabel" DefaultValue="Contoso Add-in" />
          <bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane" />
          <bt:String id="ActionButton.Label" DefaultValue="Perform an action" />
        </bt:ShortStrings>
        <bt:LongStrings>
          <bt:String id="TaskpaneButton.Tooltip"
            DefaultValue="Opens a pane displaying all available properties." />
          <bt:String id="ActionButton.Tooltip" DefaultValue="Perform an action when clicked." />
        </bt:LongStrings>
      </Resources>
      <WebApplicationInfo>
        <Id>eae6a244-13a2-4712-8f2b-f2dfb712105b</Id>
        <Resource>api://localhost:3000/eae6a244-13a2-4712-8f2b-f2dfb712105b</Resource>
        <Scopes>
          <Scope>User.Read</Scope>
          <Scope>profile</Scope>
        </Scopes>
      </WebApplicationInfo>
    </VersionOverrides>
    </VersionOverrides>
    </OfficeApp>
  2. Paste the following in commands.ts

    
    /*
    * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
    * See LICENSE in the project root for license information.
    */

/ global global, Office, self, window /

Office.onReady(() => { // If needed, Office.js is ready to be called console.log("here"); });

/**

function getGlobal() { return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : undefined; }

const g = getGlobal() as any;

// The add-in command functions need to be available in global scope g.onSendCallback = onSendCallback;



3. Click on a different email when the add-in starts processing.
4. Add-in breaks.
 - In OWA - the send button on the draft will be greyed out and Outlook has to be refreshed to enable it again.
 - In Outlook for windows - the add-in is shutdown and all progress is lost. Email is saved as a draft.

## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
The add-in shouldn't break if user switches to a different email. Furthermore, there should be consistency b.w the platforms, on how this is handled.

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. 
nancy-wang commented 1 year ago

Thanks for reporting this issue @abdumanas-plutoflume ! Tagging @exextoc to take a look into this issue.

exextoc commented 1 year ago

Thanks for reporting this issue regarding ItemSend. We are able to repro the same at our end. It has been put on our backlog. We unfortunately have no timelines to share at this point.

Internal tracking id: Office: 190632

abdumanas-plutoflume commented 1 year ago

@exextoc I can confirm that, although Outlook for windows displays a default message, it still shuts down the add-in and all progress is lost. So the issue exists not just in OWA but Outlook for windows. I have updated the Issue description.