Skip to content

Commit

Permalink
fix(module:cascader): search correctly when a root node is a leaf node
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan.zhao committed Sep 6, 2018
1 parent cca1fdd commit aa1ec2f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/cascader/nz-cascader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1227,12 +1227,13 @@ export class NzCascaderComponent implements OnInit, OnDestroy, ControlValueAcces
if (!sNode.isLeaf) {
loopParent(sNode, disabled);
}
if (sNode.isLeaf || !sNode.children) {
if (isLeafNode(sNode)) {
loopChild(sNode, disabled);
}
});
path.pop();
};
const isLeafNode = (node: CascaderOption) => node.isLeaf || !node.children || !node.children.length;
const loopChild = (node: CascaderOption, forceDisabled = false) => {
path.push(node);
const cPath = Array.from(path);
Expand All @@ -1248,7 +1249,7 @@ export class NzCascaderComponent implements OnInit, OnDestroy, ControlValueAcces
path.pop();
};

this.oldColumnsHolder[ 0 ].forEach(node => loopParent(node));
this.oldColumnsHolder[ 0 ].forEach(node => isLeafNode(node) ? loopChild(node) : loopParent(node));
if (sorter) {
results.sort((a, b) => sorter(a.path, b.path, this._inputValue));
}
Expand Down

0 comments on commit aa1ec2f

Please sign in to comment.