-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(module:cascader): search correctly when a root node is a leaf node #2108
fix(module:cascader): search correctly when a root node is a leaf node #2108
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2108 +/- ##
==========================================
+ Coverage 95.96% 95.97% +<.01%
==========================================
Files 473 473
Lines 11516 11516
Branches 1535 1535
==========================================
+ Hits 11051 11052 +1
Misses 132 132
+ Partials 333 332 -1
Continue to review full report at Codecov.
|
0013a80
to
aa1ec2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the reason is when we parse nodes in the first layer, we didn't consider that they could be leaf nodes. See line 1222 in nz-cascader.component.ts
file.
@@ -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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot say a node is a leaf node just because it has no children. Though in search mode users cannot load data asynchronously, it would confuse users when they want to load asynchronously, and breaks API consistence in different modes.
@zd5043039119 You should add a test case to cover this situation. |
aa1ec2f
to
65c6268
Compare
65c6268
to
3d4e440
Compare
LGTM |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #2104
What is the new behavior?
If a root node is also a leaf node, it can also be searched and highlighted correctly.
Does this PR introduce a breaking change?
Other information