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
686 stars 95 forks source link

Mac desktop: invoking showAsTaskpane moves the add-in to another workbook if it is in focus #3220

Open wh1t3cAt1k opened 1 year ago

wh1t3cAt1k commented 1 year ago

Related: https://github.com/OfficeDev/office-js/issues/2361

I can confirm that it used to crash Mac for us too. Though I cannot reliably catch the crash now, the fact that the add-in "jumps" to another workbook is already fishy and may lead to all sorts of issues, I suspect.

Your Environment

Expected behavior

Office.addin.showAsTaskpane() should always open the add-in in the same Excel window where it was called.

Current behavior

If another (new) Book2 is in focus at the time when Office.addin.showAsTaskpane() is invoked:

Steps to reproduce

The steps are confirmed with manual wef insertion and dev server running. Please repeat exactly the same steps in case they matter.

Minimal repro: https://github.com/VelixoSolutions/reproduce-mac-jumping-taskpane

  1. Note: the repo uses localhost port 3001, not the default 3000, change if needed.
  2. Build and add add-in manifest to the wef folder on Mac
  3. Run webpack dev server. (npm run dev-server)
  4. Open Excel and create a new workbook.
  5. Click Insert -> Addins -> add-in icon
  6. In the task pane, scroll down to "Run" button.
  7. Click "Run" button in the task pane.
  8. Quickly, within 5 seconds, open another new workbook (CTRL+N).

In a few seconds, observe task pane appeared in second workbook, and grey side panel in the first one, and the rest of the weird behaviour above.

Link to live example(s)

Live demonstration: https://www.loom.com/share/f16855696cd24127b169411c813687eb I suggest using 1.2x speed for best experience.

Provide additional details

Previously used to crash Excel (maybe still crashing under some circumstances, but not replicatable on minimal repro) - at any rate, it is already very wrong for the add-in to appear in a different window.

Context

The issue is impactful for us, because when our custom functions fail calculation because of user not being logged in to the server, we invoke showAsTaskpane() and navigate the user to connection login screen.

On Mac, this jumping behaviour leads to user confusion, previously it led to total Excel crash.

ghost commented 1 year ago

Thank you for letting us know about this issue. We will take a look shortly. Thanks.

madhavagrawal17 commented 1 year ago

@wh1t3cAt1k, I am not able to reproduce the issue locally. For me, the Taskpane stays open in "Book1". Can you check if you can reproduce this issue on windows as well?

wh1t3cAt1k commented 1 year ago

@madhavagrawal17 were you testing on Windows? It is specific to Mac only for me.

madhavagrawal17 commented 1 year ago

@wh1t3cAt1k, I tried it on both windows and Mac but cannot reproduce it locally. Are there any other details I am missing?

wh1t3cAt1k commented 1 year ago

@Wenjun-Gong @madhavagrawal17 it is replicable using the same exact steps in the bug description.

Here is another repro just from now:

image

Mac OS Ventura 13.2.1, Excel Desktop for Mac 16.71

Did you scroll down in the task pane and clicked the "Run" button, and then very quickly clicked CMD+N to bring a new workbook into focus?

madhavagrawal17 commented 1 year ago

@wh1t3cAt1k, Thank you for the information. Finally, I am able to reproduce this issue locally and started investigating this issue.

wh1t3cAt1k commented 1 year ago

Thank you. Please let us know when there's an update on the root cause or ETA/complexity!

yihuax commented 1 year ago

I did see the issue on MAC. But when I used our latest code, I found this issue no longer occurred. The version in which this issue not happening is below:

image

wh1t3cAt1k commented 1 year ago

@madhavagrawal17 @yihuax @Wenjun-Gong the issue is still happening in a variety of scenarios for us. We would appreciate if you investigate again.

jgamboavx commented 1 year ago

I'm able to reproduce this in v 16.74 Excel for Mac. The following repo is a minimal repro of this issue.

https://github.com/jgamboavx/repro-add-in-tab-on-new-workbook

Clicking on 'Create workbook' in the taskpane will create a new workbook and immediately call Office.addin.showAsTaskpane()

The taskpane will move to the newly created workbook.

image

wh1t3cAt1k commented 1 year ago

@madhavagrawal17 @yihuax @Wenjun-Gong just wanted to follow up on the issue, it is still a problem for us that necessitates hack-ish workarounds in the product.

madhavagrawal17 commented 1 year ago

Sure, We will try to reproduce this issue locally again.

yihuax commented 1 year ago

Hello @jgamboavx ! I followed your repro steps above. I have two questions:

  1. In your link, you said to run npm run dev-server and then npm start. But npm run dev-server keeps running and never finishes. How to run npm start?

  2. You said "Open the add-in taskpane. Click on the 'Create Workbook' button. (or call the =CONTOSO.NEWWORKBOOK() function). A new workbook will open. On the original workbook, the taskpane will go gray." After I clicked Create Workbook. a new workbook did open (without the taskpane opened, but I can click the button to open it). No matter whether the taskpane is opened or not in the new workbook, the original taskpane is NOT grayed out. Comments?

I am using Excel 16.76. Thanks.

I'm able to reproduce this in v 16.74 Excel for Mac. The following repo is a minimal repro of this issue.

https://github.com/jgamboavx/repro-add-in-tab-on-new-workbook

Clicking on 'Create workbook' in the taskpane will create a new workbook and immediately call Office.addin.showAsTaskpane()

The taskpane will move to the newly created workbook.

image

jgamboavx commented 1 year ago

In your link, you said to run npm run dev-server and then npm start. But npm run dev-server keeps running and never finishes. How to run npm start?

@yihuax, I should have made it clearer that npm start should be ran on a new terminal, while npm run dev-server is kept running on another.

The is according to Microsoft's tutorial .

Regarding the issue, here's a demo to better illustrate it: https://streamable.com/xpowg0

Recorded on 16.74.

jgamboavx commented 1 year ago

@yihuax Because you noted you're using Excel 16.76, I've also updated Excel to this version and can confirm the issue is still replicating on it.

wh1t3cAt1k commented 7 months ago

@madhavagrawal17 @yihuax-zz could we please revisit this issue if possible? It is still bothering us and it's been a long radio silence here. The replication scenario in https://github.com/OfficeDev/office-js/issues/3220#issuecomment-1611080957 is still relevant.

Having multiple workbooks open is very common for our scenarios and it is highly confusing when the side panel connected to one workbook "migrates" to a completely unrelated one.