Skip to content

Commit 4484674

Browse files
fix(module:tree-view): fix innerTrackBy function (#7150)
close #7118 Co-authored-by: viktorplakida <plakyda1@gmail.com>
1 parent f73be80 commit 4484674

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

components/tree-view/node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class NzTreeVirtualScrollNodeOutletDirective<T> implements OnChanges {
170170
return true;
171171
}
172172
}
173-
return false;
173+
return ctxChange.previousValue?.data !== ctxChange.currentValue?.data;
174174
}
175175
return true;
176176
}

components/tree-view/tree-virtual-scroll-view.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ export class NzTreeVirtualScrollViewComponent<T> extends NzTreeView<T> implement
6565
innerTrackBy: TrackByFunction<NzTreeVirtualNodeData<T>> = i => i;
6666

6767
ngOnChanges(changes: SimpleChanges): void {
68-
if (changes.trackBy && typeof changes.trackBy.currentValue === 'function') {
69-
this.innerTrackBy = (index: number, n) => this.trackBy(index, n.data);
70-
} else {
71-
this.innerTrackBy = i => i;
68+
if (changes.trackBy) {
69+
if (typeof changes.trackBy.currentValue === 'function') {
70+
this.innerTrackBy = (index: number, n) => this.trackBy(index, n.data);
71+
} else {
72+
this.innerTrackBy = i => i;
73+
}
7274
}
7375
}
7476

0 commit comments

Comments
 (0)