I was able to bypass this one using selectedTabChange() method.
<mat-tab-group [(selectedIndex)]="myIndex" (selectedTabChange)="onIndexChange()"> ... </mat-tab-group>
this.myIndex = 0
this.previousIndex = 0
onIndexChange() {
if (this.previousIndex !== this.myIndex && myCondition) {
let text = "My message";
if (confirm(text) == true) {
this.previousIndex = this.myIndex;
}
else {
this.myIndex= this.previousIndex;
}
} else {
this.previousIndex = this.myIndex;
}
}
you can visually see the tab revert back to your previous one with this small snippet. Went through the documentation to understand there is no way we can block tab change. But using selectedTabChange() method, we can detect the action and perform our condition check(i am using an alertbox) and then revert the myIndex value back to original.