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

Ranges behave different after replacing in Word on Web and on desktop #3362

Open gion-andri opened 1 year ago

gion-andri commented 1 year ago

Provide required information needed to triage your issue

Replacing a range behaves different in Word on web and on desktop

Your Environment

macOS

Web

Expected behavior

To work with the APIs, I expect them to behave the same on both platforms.

Current behavior

The same API works different on different platforms. This makes it difficult to use the results to continue.

Steps to reproduce

  1. Install that Gist in Script Lab: https://gist.github.com/gion-andri/c9e02c520d023169123bc274a6fd4501
  2. Click the Setup button to create a simple content for the word document.
  3. Click the Run button to execute the code. It logs the text content in the range after the replace operation into the document.

When run on the web, it contains

Range contains before replacing: shrt sentence. 
Range contains after replacing: short sentence 

(mind the missing period after the second sentence: The range has still the same size and startingpoint, but as the sentence is longer now, the period is not part of the range anymore).

When run on Word for macOS, it containes

Range contains before replacing: shrt sentence.
Range contains after replacing:  sentence.

(the replaced word is not part of the range anymore, the range starts with the space character after the first word. But it still contains the period after the sentence)

Link to live example(s)

  1. https://gist.github.com/gion-andri/c9e02c520d023169123bc274a6fd4501

Context

We suggest changes to the text the user enters. We need the text of a paragraph after we replaced a word in it to create the next suggestion.

Useful logs

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.

ghost commented 1 year ago

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

xiaoyuMS commented 1 year ago

Hi @gion-andri Thanks for reporting this. The current range object is not a dynamic range on Word Web while it should be adjusted properly on Desktop. So there should be two potential bugs:

  1. The range object can't adjust itself when it is changed on Word Web.
  2. The range object gets shrunk when there is a sub-range that gets replaced on Word Desktop.

Two bugs have been created for internal tracking VSO#7908063, VSO#7908067.

gion-andri commented 10 months ago

@xiaoyuMS Do you have any news on this?

xiaoyuMS commented 10 months ago

@gion-andri Sorry for the inconvenience caused by the bug. We appreciate your patience and understanding as we need to prioritize the work item in the backlog.

xiruatms commented 4 months ago

@gion-andri , we've provided a fix. It'll be rolled-out soon.

gion-andri commented 4 months ago

Where will it be rolled out? Did u fix VSO#7908063 and VSO#7908067 ?