Skip to content

Commit

Permalink
fix(primeng/p-treeSelect): reset partial selected tree item
Browse files Browse the repository at this point in the history
  • Loading branch information
volvachev authored and Egor Volvachev committed Oct 16, 2022
1 parent b3e7b35 commit 55ed833
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/app/components/treeselect/treeselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ export class TreeSelect implements AfterContentInit {
clear(event) {
this.value = null;
this.resetExpandedNodes();
this.resetPartialSelected();
this.onModelChange(this.value);
this.onClear.emit();

Expand Down Expand Up @@ -403,6 +404,7 @@ export class TreeSelect implements AfterContentInit {
if (this.value) {
let selectedNodes = this.selectionMode === "single" ? [this.value] : [...this.value];
this.resetExpandedNodes();
this.resetPartialSelected();
if (selectedNodes && this.options) {
this.updateTreeBranchState(null, null, selectedNodes);
}
Expand Down Expand Up @@ -455,6 +457,20 @@ export class TreeSelect implements AfterContentInit {
this.expandedNodes = [];
}

resetPartialSelected(nodes = this.options): void {
if (!nodes) {
return;
}

for (let node of nodes) {
node.partialSelected = false;

if (node.children && node.children?.length > 0) {
this.resetPartialSelected(node.children);
}
}
}

findSelectedNodes(node, keys, selectedNodes) {
if (node) {
if (this.isSelected(node)) {
Expand Down

0 comments on commit 55ed833

Please sign in to comment.