Skip to content

Commit

Permalink
Merge pull request #15397 from LinkTheFirstFlame/issue-15193-tree-res…
Browse files Browse the repository at this point in the history
…ult-not-updated-when-new-data-is-added

Tree: Update filtered nodes on nodes value changes
  • Loading branch information
cetincakiroglu authored May 3, 2024
2 parents 4565538 + 93d2330 commit 3530b25
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/components/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,9 @@ export class Tree implements OnInit, AfterContentInit, OnChanges, OnDestroy, Blo
ngOnChanges(simpleChange: SimpleChanges) {
if (simpleChange.value) {
this.updateSerializedValue();
if (this.hasFilterActive()) {
this._filter(this.filterViewChild.nativeElement.value);
}
}
}

Expand Down Expand Up @@ -1414,6 +1417,10 @@ export class Tree implements OnInit, AfterContentInit, OnChanges, OnDestroy, Blo
return this.filter && this.filteredNodes && this.filteredNodes.length;
}

hasFilterActive() {
return this.filter && this.filterViewChild?.nativeElement?.value.length > 0
}

getNodeWithKey(key: string, nodes: TreeNode<any>[]): TreeNode<any> | undefined {
for (let node of nodes) {
if (node.key === key) {
Expand Down

0 comments on commit 3530b25

Please sign in to comment.