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

Using `search(...)` throws `SearchDialogIsOpen` when the advanced search dialog is open #4922

Open greysteil opened 3 weeks ago

greysteil commented 3 weeks ago

Provide required information needed to triage your issue

Using the search(...) function when a user has the advanced search dialog open throws a SearchDialogIsOpen error.

Your Environment

Expected behavior

Using search(...) should return results regardless of whether the user has the advanced search dialog open.

Current behavior

Using the search(...) function when a user has the advanced search dialog open throws a SearchDialogIsOpen error.

Steps to reproduce

  1. Open the advanced search dialog
  2. Run a search from an add-in:
    await Word.run(async (context) => {
    let ooxml = context.document.body.search("some text")
    await context.sync();
    })
  3. Observe a SearchDialogIsOpen error

Context

The search(...) function is critical to our app. We use it to find and then track locations in the document, which we then annotate, suggest changes to, scroll to, etc.. Without it we have no way to get those locations.

As a result of this issue, we have to show an error message in our app when a user has the advanced search dialog open and we try to do almost anything. The user then has to close the search dialog in order to perform actions from our app.

I'm guessing the presence of a specific error for this case means it's a known issue on the OfficeJS side, but I'm opening this issue because search(...) is foundational to so many apps (I'm sure my use cases aren't unusual). Would it be possible to support API searches even when the advanced search dialog is open?

microsoft-github-policy-service[bot] commented 3 weeks ago

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

shanshanzheng-dev commented 3 weeks ago

Hi @greysteil Thanks for reporting this issue. I can repro it. We'll take a look and report back if we have a suggestion for you.

wangyun-microsoft commented 3 weeks ago

Hi @greysteil,

Is your use case that the end users need to keep both advanced search dialog and your search pane open at the same time?

greysteil commented 3 weeks ago

The user has the advanced search dialog open for some reason that's unrelated to our add-in (it's just the way they're doing their work). I'd like to avoid having to ask them to close it, because I don't want our add-in to intrude on the way they're doing their other work.

Basically I want my add-in to be as un-intrusive as possible - it shouldn't make users take actions they don't want to / don't expect to have to take. The inability to use search(...) if the user has the advanced search dialog open is forcing me to ask the user to take an action that they wouldn't expect to have to take - to them, the fact my add-in uses search(...) to do its work, and that that's incompatible with the advanced search window being open, are implementation details they don't want to think about.