title: Angular mat-tab forming tab toggling on its own when selected fast
body: <p>Having an issue using angular material's mat-tab, where if tabs are toggled really fast it starts toggling between tabs infinitely, along with the content of the tab.</p>
  <blockquote>
  <p>the ts file</p>
  </blockquote>
  <pre><code>
      tabChanged = (tabChangeEvent: MatTabChangeEvent): void =&gt; {
              this.selectedTabIndex = tabChangeEvent.index;
              this.toggleColorTab1 = &quot;accent&quot;
              this.toggleColorTab2 = &quot;accent&quot;
              this.Table1 = false;
              this.Table2 = false;
              if (this.selectedTabIndex == 0) {
                  this.toggleColorTab1 = &quot;primary&quot;
                  this.Table1 = true;
                  //table1 api-call
              } else if (this.selectedTabIndex == 1) {
                  this.toggleColorTab2 = &quot;primary&quot;
                  this.Table2 = true;
                  //table2 api-call
              }
          } 
  
  </code></pre>
  <blockquote>
  <p>the html file</p>
  </blockquote>
  <pre><code>
  &lt;mat-tab-group [(selectedIndex)]=&quot;selectedTabIndex&quot;
                             (selectedTabChange)=&quot;tabChanged($event)&quot;&gt;
                &lt;mat-tab label=&quot;Tab 1&quot;
                         [aria-label]=&quot;toggleColorTab1&quot;&gt;
                &lt;/mat-tab&gt;
                &lt;mat-tab label=&quot;Tab 2&quot;
                         [aria-label]=&quot;toggleColorTab2&quot;&gt;
                &lt;/mat-tab&gt;
              &lt;/mat-tab-group&gt;
  
  </code></pre>
  <ul>
  <li>Example: happens when I select tab1 then tab2 then swap back really fast back to tab1 then tab2 repeatedly then the tabs as well as the content keeps toggling unless I refresh the page or log-out*
  <strong>P.S: i think its similar to this question asked ,but this problem still occurs whether or not i use an api call on any tab selection</strong>
  <a href="https://stackoverflow.com/questions/62029833/mat-tab-group-angular-component-tab-toggling-tab-on-its-own">Mat-tab-group angular component tab toggling tab on its own</a></li>
  </ul>