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

Content Control `contentControlExited` event inconsistent across platforms #4492

Open AndyHolt opened 6 months ago

AndyHolt commented 6 months ago

Provide required information needed to triage your issue

Your Environment

Expected behavior

When cursor is in a Content Control, using arrow keys to move out of the content control triggers contentControlExited event when cursor leaves the content control

Current behavior

Currently, contentControlExited event is triggered as expected when mouse used to click outside of the content control, but on Word on Mac, using the arrow keys does not consistently trigger the event (it does sporadically). In Office on the Web, both clicking outside and using the arrow keys to move outside the content control consistently trigger the contentControlExited event.

The same appears to be true of contentControlEntered event, though I haven't tested this so rigorously.

Steps to reproduce

  1. Create a content control
  2. In Word Add-On, add function to run when content control exited. E.g.

    
    await Word.run(async (context) => {
    const contentControls = context.document.contentControls;
    contentControls.load("tag")
    await context.sync()
    
    const eventContexts = []
    
    if (contentControls.items.length) {
        for (let i = 0; i < contentControls.items.length; i++) {
            eventContexts[i] = contentControls.items[i].onExited.add(() => {console.log("Content control exited!")})
            contentControls.items[i].track()
        }
    
            await context.sync()
    } else {
        console.log("No content controls found, so can't register event handlers"))
    }

})


4. From the content control, click outside the content control, exit event fires.
5. From the content control, use arrow keys to move outside the content control. On Office on the Web, event fires, but on Word on Mac, event does not fire (except sporadically).

## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
Enterprise add-in (Schemeflow) gives inconsistent performance for content controls used throughout documents. This has a significant negative impact on users who find the experience unreliable, impacting adoption and usage of our product.

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. 
shanshanzheng-dev commented 6 months ago

Hi @AndyHolt, Sorry for slow response. We're looking into this problem, thanks for reporting! we will report back here if we have an investigation.

jipyua commented 6 months ago

hi @AndyHolt , thanks for reporting this issue. We tried arrow key move and it's true that sometimes the key move around the boundary is not triggering the event (when we move the selection just 1 position outside the content control, acturally this is also true for mouse move). We will update the thread once we found the root cause. Thanks.

jipyua commented 6 months ago

hi @AndyHolt , for this issue we have internally made a fix and now it's under the process of validation and deployment rollout. It should be available early next month with the latest M365 office update, please update your Office to the latest and have a try then. Thanks.

AndyHolt commented 6 months ago

Great, thanks very much!