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
671 stars 96 forks source link

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

Open buzzo123 opened 6 days ago

buzzo123 commented 6 days 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 3 days 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 3 days ago

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