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

Current Outlook item is incorrect when switching from invitation to email when pinned #3267

Closed arturs-buls closed 5 months ago

arturs-buls commented 1 year ago

Message from office-js bot: We’re closing this issue because it has been inactive for a long time. We’re doing this to keep the issues list manageable and useful for everyone. If this issue is still relevant for you, please create a new issue. Thank you for your understanding and continued feedback.

If user is scrolling through their email (for example - using arrow keys) and stop on some email - there are chances that Addin will get out of sync from Office.context.mailbox.item and will show Event data instead of current email. At the same time - if you call Office.context.mailbox.item.categories.addAsync it will actually add category to correct current item.

Provide required information needed to triage your issue

Your Environment

Expected behavior

Current behavior

Office.context.mailbox.item may be not aligned with actually opened mailbox item

Steps to reproduce

Use following this Gist

Setup: Get event invitation and email into Inbox folder. Steps to reproduce

  1. Open email
  2. Open sidebar and pin it
  3. Switch to event and then to email quickly
  4. Observe that sidebar is displaying Title and start time of event in invitation
  5. Open browser console
  6. Click on "Add category". Observe that "Yellow category" is added to actual current item

Link to live example(s)

https://gist.github.com/arturs-buls/38798020de8432ad0ff651150fc44476

Provide additional details

See steps to reproduce. Important part is that sidebar should be pinned

Context

In our case this is causing issue of setting categories to wrong items. Since sidebar is not detecting any new items - it is analyzing event, makes decision to add category, but category gets added to other mailbox item.

After some testing I found out that Office.EventType.ItemChanged event hander is fired with some delay for invitations, but it is fired immediately for email, causing race condition. Didn't find any workaround (tried to use setInterval to monitor Office.context.mailbox.item on my own, but it seems that internal state of office.js has wrong value as well).

Useful logs

Video with reproduction

https://user-images.githubusercontent.com/20514322/229431474-7501c39d-1cff-4530-9780-88a86280b116.mp4

exextoc commented 1 year ago

Thanks for reporting the issue , can you please share the repro video for this issue which will help in reproing this issue ??

arturs-buls commented 1 year ago

@exextoc Thanks for the response. Attached video with minimal reproduction to my report so it would be pinned in top. Small breakdown: On ItemChanged event I log subject of Office.context.mailbox.item. Also I launch setTimeout to log out subject of current item (in hopes of that at some point Office.context.mailbox.item will contain actually selected item). Both of them show event data instead of email one. In console log you can observe that ItemChanged is fired immediately for email, but for event there is slight delay, so event one is fired after email one.

When Adding category - current item is actually updated.

Our users don't click on buttons to add category, it is async and automatic process on ItemChanged, so we don't have real workaround to prevent unnecessary tags from adding

exextoc commented 1 year ago

Thanks for reporting this issue. It has been put on our backlog. We unfortunately have no timelines to share at this point

Internal tracking id: 200766