Teams configurable tab disable remove button

Brass Contributor

setValidityState doesn't work correctly on tab removal page , if we set the setValidityState to false it gets enable after few seconds.
But for the save Button is working as expected.
in the documents it suggests setValidityState(false) works in same way for save and remove but that is not the case.

the version of the microsoft-teams-library-js is 1.10.0

 

8 Replies
We are looking into this issue, We will update you.
Could you please share the document you are referring to? and also the repro steps.

this is the link
https://docs.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/create-tab-pages/removal-page

import * as microsoftTeams from "@microsoft/teams-js";
import { initializeIcons } from "@fluentui/react";
import { Provider, Button, Segment, teamsTheme } from "@fluentui/react-northstar";
import React, { useEffect, useState } from 'react';
import { useTeams } from "msteams-react-base-component";

initializeIcons();

const Remove = () => {

const [{ context }] = useTeams({});
const[remove,setRemove]=useState(false);

useEffect(() => {
if (context) {
if(context.frameContext==="remove"){
setRemove(true);
microsoftTeams.settings.setValidityState(false);
microsoftTeams.settings.registerOnRemoveHandler((removeEvent) => {
microsoftTeams.settings.getSettings((settings) => {
settings.contentUrl = "https://localhost:8080/#/channel"
});
removeEvent.notifySuccess();
});
}
}
}, [context]);

return (
<Provider theme={teamsTheme}>
{remove && <>
<Segment content={
<>
<h3>Are You Sure, You Want To Remove The Tab</h3>
<h3>Click on Continue to Remove</h3>
<Button content="Continue" style={{ marginTop:"5%" ,marginLeft: "360px" }} primary onClick={()=>{microsoftTeams.settings.setValidityState(true)}}/>
</>}/>
</>}
</Provider>
)
}
export default Remove;


the Remove button gets enabled after few seconds. even when i dont click on the button

@Umag98 - In the documentation it is mentioned that Teams enables the Remove button after five seconds.

MeghanaMSFT_0-1635423181081.png

 

Thanks,

Meghana

----------------------------------------------------------------------------------------------------------------

If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.

@Meghana-MSFT , it mentions if we wont set setValidity. but i have set it to false

but here it is mentioned that it can indicate the save is enabled or disabled. 

Umag98_0-1635424162042.png

 

@Meghana-MSFT- Can't we handle the remove button similar to save button?

We are setting up this sample. We will update you.

@umag - We checked with the engineering team. This behavior is by design as they do not want to allow app developers to completely block the user from deleting a tab.

 

Thanks, 

Meghana

---------------------------------------------------------------------------------------------------------

If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.