Skip to content

Commit

Permalink
fix(module:tree-view): fix innerTrackBy function (#7150)
Browse files Browse the repository at this point in the history
close #7118
Co-authored-by: viktorplakida <plakyda1@gmail.com>
  • Loading branch information
plakyda-codefresh committed Jan 13, 2022
1 parent f73be80 commit 4484674
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/tree-view/node.ts
Expand Up @@ -170,7 +170,7 @@ export class NzTreeVirtualScrollNodeOutletDirective<T> implements OnChanges {
return true;
}
}
return false;
return ctxChange.previousValue?.data !== ctxChange.currentValue?.data;
}
return true;
}
Expand Down
10 changes: 6 additions & 4 deletions components/tree-view/tree-virtual-scroll-view.ts
Expand Up @@ -65,10 +65,12 @@ export class NzTreeVirtualScrollViewComponent<T> extends NzTreeView<T> implement
innerTrackBy: TrackByFunction<NzTreeVirtualNodeData<T>> = i => i;

ngOnChanges(changes: SimpleChanges): void {
if (changes.trackBy && typeof changes.trackBy.currentValue === 'function') {
this.innerTrackBy = (index: number, n) => this.trackBy(index, n.data);
} else {
this.innerTrackBy = i => i;
if (changes.trackBy) {
if (typeof changes.trackBy.currentValue === 'function') {
this.innerTrackBy = (index: number, n) => this.trackBy(index, n.data);
} else {
this.innerTrackBy = i => i;
}
}
}

Expand Down

0 comments on commit 4484674

Please sign in to comment.