Skip to content

Commit 6bde019

Browse files
Added track by to tab component. Resolves #1224. (#1226)
1 parent c41f9b6 commit 6bde019

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

spa/src/app/shared/hca-tab/hca-tab.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<div class="wrapper">
22
<ng-container *ngIf="tabs">
33
<div class="hca-tabs">
4-
<div [ngClass]="getTabClass(activeTab.key, tab.key)" *ngFor="let tab of tabs" (click)="onClickTab(tab)">
4+
<div *ngFor="let tab of tabs;trackBy: trackByFn"
5+
[ngClass]="getTabClass(activeTab.key, tab.key)"
6+
(click)="onClickTab(tab)">
57
{{tab.displayName}}
68
</div>
79
</div>

spa/src/app/shared/hca-tab/hca-tab.component.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import {
1414
// App dependencies
1515
import EntitySpec from "../../files/shared/entity-spec";
1616

17-
// App dependencies
18-
1917
@Component({
2018
selector: "hca-tab",
2119
templateUrl: "./hca-tab.component.html",
@@ -32,10 +30,6 @@ export class HCATabComponent {
3230
// Outputs
3331
@Output() tabSelected = new EventEmitter<EntitySpec[]>();
3432

35-
/**
36-
* Public API
37-
*/
38-
3933
/**
4034
* Return the set of CSS class names that are applicable to the tab.
4135
*
@@ -61,4 +55,16 @@ export class HCATabComponent {
6155
this.tabSelected.emit(tab);
6256
}
6357

58+
/**
59+
* Track by function used when displaying the set of tabs.
60+
*
61+
* @param {number} index
62+
* @param {EntitySpec} tab
63+
* @returns {string}
64+
*/
65+
public trackByFn(index: number, tab: EntitySpec): string {
66+
67+
return tab.key;
68+
}
69+
6470
}

0 commit comments

Comments
 (0)