@@ -98,7 +98,7 @@ export class TabsTestComponent {
9898 template : `
9999 <div #wrapperDiv style="display: flex;">
100100 <igx-tabs>
101- @for (tab of collection; track tab) {
101+ @for (tab of collection; track trackByItemRef( tab) ) {
102102 <igx-tab-item>
103103 <igx-tab-header><span igxTabHeaderLabel>{{ tab.name }}</span></igx-tab-header>
104104 <igx-tab-content></igx-tab-content>
@@ -112,7 +112,7 @@ export class TabsTestComponent {
112112export class TabsTest2Component {
113113 @ViewChild ( IgxTabsComponent , { static : true } ) public tabs : IgxTabsComponent ;
114114 @ViewChild ( 'wrapperDiv' , { static : true } ) public wrapperDiv : any ;
115- public collection : any [ ] ;
115+ protected collection : any [ ] ;
116116
117117 constructor ( ) {
118118 this . resetCollectionThreeTabs ( ) ;
@@ -151,6 +151,9 @@ export class TabsTest2Component {
151151 public resetToEmptyCollection ( ) {
152152 this . collection = [ ] ;
153153 }
154+
155+ /** Explicitly track object so collection changes entirely for index logic test */
156+ protected trackByItemRef = ( x : any ) => x ;
154157}
155158
156159@Component ( {
@@ -198,7 +201,7 @@ export class TemplatedTabsTestComponent {
198201 template : `
199202 <div>
200203 <igx-tabs [selectedIndex]="2">
201- @for (tab of collection; track tab) {
204+ @for (tab of collection; track tab.name ) {
202205 <igx-tab-item>
203206 <igx-tab-header><span igxTabHeaderLabel>{{ tab.name }}</span></igx-tab-header>
204207 </igx-tab-item>
@@ -210,7 +213,7 @@ export class TemplatedTabsTestComponent {
210213} )
211214export class TabsTestSelectedTabComponent {
212215 @ViewChild ( IgxTabsComponent , { static : true } ) public tabs : IgxTabsComponent ;
213- public collection : any [ ] ;
216+ protected collection : any [ ] ;
214217
215218 constructor ( ) {
216219 this . collection =
@@ -525,7 +528,7 @@ export class TabsWithPrefixSuffixTestComponent extends TabsTestComponent {
525528 template : `
526529 <div #wrapperDiv>
527530 <igx-tabs>
528- @for (contact of contacts; track contact) {
531+ @for (contact of contacts; track contact.Name ) {
529532 <igx-tab-item>
530533 <igx-tab-header>
531534 <span igxTabHeaderLabel>{{contact.Name}}</span>
@@ -547,7 +550,7 @@ export class TabsContactsComponent extends TabsTestComponent {
547550 template : `
548551 <div #wrapperDiv style="display: flex;">
549552 <igx-tabs>
550- @for (tab of collection; track tab) {
553+ @for (tab of collection; track tab.name ) {
551554 <igx-tab-item [(selected)]="tab.selected">
552555 <igx-tab-header><span igxTabHeaderLabel>{{ tab.name }}</span></igx-tab-header>
553556 <igx-tab-content></igx-tab-content>
@@ -560,25 +563,25 @@ export class TabsContactsComponent extends TabsTestComponent {
560563} )
561564export class AddingSelectedTabComponent {
562565 @ViewChild ( IgxTabsComponent , { static : true } ) public tabs : IgxTabsComponent ;
563- public collection : any [ ] ;
566+ protected collection : any [ ] ;
564567 constructor ( ) {
565568 this . collection = [
566569 { name : 'tab1' , selected : true } ,
567570 { name : 'tab2' , selected : false }
568571 ] ;
569572 }
570573
571- public addTab ( num : number ) {
574+ public addTab ( ) {
572575 this . collection . forEach ( t => t . selected = false ) ;
573- this . collection . push ( { name : 'tab' + num , selected : true } ) ;
576+ this . collection . push ( { name : 'tab' + ( this . collection . length + 1 ) , selected : true } ) ;
574577 }
575578}
576579
577580@Component ( {
578581 template : `
579582 <div #wrapperDiv>
580583 <igx-tabs>
581- @for (tab of collection; track tab) {
584+ @for (tab of collection; track tab.name ) {
582585 <igx-tab-item>
583586 <igx-tab-header><span igxTabHeaderLabel>{{ tab.name }}</span></igx-tab-header>
584587 <igx-tab-content></igx-tab-content>
@@ -592,18 +595,15 @@ export class AddingSelectedTabComponent {
592595export class TabsRtlComponent {
593596 @ViewChild ( IgxTabsComponent , { static : true } ) public tabs : IgxTabsComponent ;
594597 @ViewChild ( 'wrapperDiv' , { static : true } ) public wrapperDiv : any ;
595- public collection : any [ ] ;
596- constructor ( ) {
597- this . collection = [
598- { name : 'tab1' , selected : true } ,
599- { name : 'tab2' , selected : false } ,
600- { name : 'tab3' , selected : false } ,
601- { name : 'tab4' , selected : false } ,
602- { name : 'tab5' , selected : false } ,
603- { name : 'tab6' , selected : false } ,
604- { name : 'tab7' , selected : false } ,
605- { name : 'tab8' , selected : false } ,
606- { name : 'tab9' , selected : false } ,
607- ] ;
608- }
598+ protected collection = [
599+ { name : 'tab1' , selected : true } ,
600+ { name : 'tab2' , selected : false } ,
601+ { name : 'tab3' , selected : false } ,
602+ { name : 'tab4' , selected : false } ,
603+ { name : 'tab5' , selected : false } ,
604+ { name : 'tab6' , selected : false } ,
605+ { name : 'tab7' , selected : false } ,
606+ { name : 'tab8' , selected : false } ,
607+ { name : 'tab9' , selected : false } ,
608+ ] ;
609609}
0 commit comments