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

Excel.run() Operations Blocked While Data Validation Dropdown Is Open #4936

Open buzzo123 opened 2 months ago

buzzo123 commented 2 months ago

Description:

I'm developing an Excel add-in using Office.js and I've encountered a problem when a data validation dropdown (list) is open in a cell. While the dropdown is open, all operations triggered via Excel.run() are queued and remain in a waiting state until the dropdown is closed by the user.

I would like to be able to either:

  1. Force Excel.run() operations to execute while a dropdown is open, or
  2. Detect when the dropdown is open and handle the interaction accordingly.

Currently, it seems that Excel enters a modal state while the dropdown is open, preventing any Office.js operations from executing until the interaction is finished. This causes delays in my add-in when users interact with cells that have data validation lists.

Steps to Reproduce:

  1. Create a data validation dropdown in a cell (e.g., A1) using Excel's built-in data validation.
  2. Open the dropdown in that cell.
  3. Try to run any Excel.run() operation, such as setting a value in another cell, while the dropdown is still open.

Expected Behavior:

Actual Behavior:

Example Code:

Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getActiveWorksheet();
    const range = sheet.getRange("A2");

    // Open a dropdown (user interaction required)
    // While the dropdown is open, this operation is blocked
    range.values = [["New Value"]];
    await context.sync(); // This operation waits until the dropdown is closed
});

Possible Workarounds:

I've tried some workarounds, such as retrying operations after a delay or handling onSelectionChanged events, but these are not ideal because they do not solve the issue of detecting the dropdown's modal state.

Environment:

Request:

AlexJerabek commented 2 months ago

Hi @buzzo123,

Thank you for raising this issue. I don't believe there is an API that will solve your scenario here. I'm going to transfer this issue to the product repo (office-js) so the feature crew sees this.

microsoft-github-policy-service[bot] commented 2 months ago

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

qinliuMSFT commented 1 month ago

Hi @buzzo123 , thank you for reporting this issue. I can reproduce this issue on win32 application, but not on Excel online. Can you help confirm this? Meanwhile, the team will investigate your request and we will reply to you as soon as there is progress. Thank you for your patience.

buzzo123 commented 1 month ago

Hi @qinliuMSFT, thanks for the update. I can confirm it’s happening on the Win32 app but not on Excel Online. Let me know if you need anything else from me. Thanks.

qinliuMSFT commented 1 month ago

Thanks for the confirm. The issue has been put on our backlog #9396269, we will report back if we have any suggestion for you.