Topic: Mdb-tabset select method called many times

bitjuice pro asked 3 years ago


Actual behavior

Hi,

I'm using mdb-tabset with dynamic tabs. When tabs are created in template, I notice that (select) method is called automatically many times: n times + 1 (where n is the number of tabs). This is a big issue when in select method I call an API method and after I set a variable used to render the content of the active tab: API method is called for each tabs and the variable is set with the last response of the API, which may not coincide with the active tab.

Resources (screenshots, code snippets etc.)

<mdb-tabset #staticTabs [buttonClass]="'md-tabs tabs-orange tabs-3'" [contentClass]="'card'">
  <mdb-tab *ngFor="let tab of tabs" heading="{{ tab.title }}" (select)="onSelect($event)">
    {{ tab.content }}
  </mdb-tab>
</mdb-tabset>


  @ViewChild('staticTabs', { static: true }) staticTabs?: TabsetComponent;

  tabs: any[] = [
    { title: 'Dynamic Tab 1', content: 'Dynamic tab content 1' },
    { title: 'Dynamic Tab 2', content: 'Dynamic tab content 2' },
    { title: 'Dynamic Tab 3', content: 'Dynamic tab content 3' },
    { title: 'Dynamic Tab 4', content: 'Dynamic tab content 4' }
  ];

Grzegorz Bujański staff commented 3 years ago

Hi. Can you say more about it? Can I reproduce this? I checked the code you paste and the select method called only once.


noveltytech priority commented 2 years ago

I'm also having the same problem,(select)="onSelect($event)" method is called even when we try to switch another component module.


Arkadiusz Idzikowski staff commented 2 years ago

@noveltytech Can you provide an example HTML/TS code on which we will be able to reproduce this problem? Which version of MDB Angular do you use?



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Opened

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 9.4.0
  • Device: PC
  • Browser: Chorme
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No