Oct 24 2021 11:06 PM - edited Oct 25 2021 10:59 AM
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
Oct 26 2021 12:54 AM
Oct 26 2021 11:28 PM
Oct 26 2021 11:37 PM - edited Oct 27 2021 09:47 AM
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
Oct 28 2021 05:14 AM
@Umag98 - In the documentation it is mentioned that Teams enables the Remove button after five seconds.
Thanks,
----------------------------------------------------------------------------------------------------------------
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.
Oct 28 2021 05:31 AM - edited Oct 28 2021 05:31 AM
@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.
Oct 31 2021 06:06 AM
@Meghana-MSFT- Can't we handle the remove button similar to save button?
Nov 01 2021 10:53 PM
Nov 10 2021 09:17 PM - edited Nov 10 2021 09:18 PM
@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.