OfficeDev / microsoft-teams-library-js

JavaScript library for use by Microsoft Teams apps
https://docs.microsoft.com/microsoftteams/platform/
Other
434 stars 199 forks source link

Context contains wrong information in Outlook after pages.currentApp.navigateTo #1925

Open ichivers opened 1 year ago

ichivers commented 1 year ago

In outlook.office.com using app.pages.getContext() doesn't return the correct pageId or subPageId after navigating using pages.currentApp.navigateTo.

When I click the button on TabA to navigate to TabB in Outlook, the console output in TabB returns incorrect pageId. I expect it to show the pageId of TabB.

TabA.tsx code:

import { useContext } from "react"; import { TeamsFxContext } from "./Context"; import { pages } from "@microsoft/teams-js";

export default function TabA() { const { themeString } = useContext(TeamsFxContext);

const handleClick = ()=> { console.log('pages.currentApp.isSupported', pages.currentApp.isSupported()) if(pages.currentApp.isSupported()){ pages.currentApp.navigateTo({pageId: 'index2', subPageId: 'x'}) } else { pages.navigateToApp({appId: 'xxxxx', pageId: 'index2', subPageId: 'y'}) } }

return ( <div className={themeString === "default" ? "light" : themeString === "dark" ? "dark" : "contrast"}

Tab A

  <button onClick={handleClick}>Goto Tab B</button>
</div>

); }

TabB.tsx code:

import { useContext, useEffect, useState } from "react"; import { TeamsFxContext } from "./Context"; import { app } from "@microsoft/teams-js";

export default function TabB() { const { themeString } = useContext(TeamsFxContext);

useEffect(() => { // I expect to see index2 pageId here, but I don't! if(app.isInitialized()){ app.getContext().then((context) => { console.log('index2 app is initialized context ', context) }) } else { app.initialize().then(() => { app.getContext().then((context) => { console.log('index2 app NOT initialized context ', context) }) }) } }, [])

return ( <div className={themeString === "default" ? "light" : themeString === "dark" ? "dark" : "contrast"}

Tab B

); }

Here is the snippet from the manifest:

"staticTabs": [ { "entityId": "index0", "name": "Personal Tab", "contentUrl": "${{TAB_ENDPOINT}}/index.html#/tab", "websiteUrl": "${{TAB_ENDPOINT}}/index.html#/tab", "scopes": [ "personal" ] }, { "entityId": "index1", "name": "Tab A", "contentUrl": "${{TAB_ENDPOINT}}/index.html#/tabA", "websiteUrl": "${{TAB_ENDPOINT}}/index.html#/tabA", "scopes": [ "personal" ] }, { "entityId": "index2", "name": "Tab B", "contentUrl": "${{TAB_ENDPOINT}}/index.html#/tabB", "websiteUrl": "${{TAB_ENDPOINT}}/index.html#/tabB", "scopes": [ "personal" ] } ],

Full code available here: https://github.com/ichivers/BasicTabs/

Have tried with the latest teams-js package.

microsoft-github-policy-service[bot] commented 1 year ago

Hi ichivers! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform

nwojod-MSFT commented 1 year ago

@ichivers thank you for reporting this issue. We will investigate this on our end and update you with our findings. Thanks.

nwojod-MSFT commented 1 year ago

@ichivers additionally, what platform are you running this on, web or desktop? We were able to repro the same issue, and the team is currently working on this.

ichivers commented 1 year ago

I was using web.

nwojod-MSFT commented 1 year ago

@ichivers thanks for confirming. We have raised a bug for this and currently working on resolving this issue. We do not have an ETA yet, but I will keep you updated on the timeline.

nuttmeister commented 1 year ago

I'm having same/similar issue. Where using navigateTo and setting subPageId to add additional data to the tab it will never, ever reset subPageId.

So when accessing the tab from the main menu where no subPageId is set, it's still set, and it doesn't seem to be possible to unset / reset it.

ChetanSharma-msft commented 11 months ago

Hello Everyone, Sorry for delay in response.

Engineering team is already looking into this issue, we will let you know once we have any updates.