Skip to content
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

cascader can not filter correctly when a node has no children #2104

Closed
zd5043039119 opened this issue Sep 5, 2018 · 8 comments
Closed

cascader can not filter correctly when a node has no children #2104

zd5043039119 opened this issue Sep 5, 2018 · 8 comments
Assignees
Labels

Comments

@zd5043039119
Copy link
Contributor

zd5043039119 commented Sep 5, 2018

Version

1.4.1

Environment

Angular 6.1.3,Chrome 67.0.3396.87

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-start-mshvaz

Steps to reproduce

  1. 触发Cascader,并使焦点聚集在输入框
  2. 输入Test这个单词的任意结果

What is expected?

能出现高亮的Test选项

What is actually happening?

Not Found

Other?

@wzhudev wzhudev self-assigned this Sep 5, 2018
@wzhudev
Copy link
Member

wzhudev commented Sep 5, 2018

@zd5043039119 Please provide the edit link, not just the demo.

@zd5043039119
Copy link
Contributor Author

@wendzhue Updated

@wzhudev
Copy link
Member

wzhudev commented Sep 6, 2018

@zd5043039119 You didn't mark the node as isLeaf so it would treated as a non-leaf node, which means it shouldn't be able to dispatch a value at all.

@wzhudev wzhudev closed this as completed Sep 6, 2018
@wzhudev
Copy link
Member

wzhudev commented Sep 6, 2018

But it do have a problem. I would fix it for another issue.

@zd5043039119
Copy link
Contributor Author

zd5043039119 commented Sep 6, 2018

@wendzhue i updated the reproduction link and mark the node as isLeaf, but get the same result, and i read the source code,

const loopParent = (node: CascaderOption, forceDisabled = false) => {
      const disabled = forceDisabled || node.disabled;
      path.push(node);
      node.children.forEach((sNode) => {
        if (!sNode.parent) { sNode.parent = node; } /** 搜索的同时建立 parent 连接,因为用户直接搜索的话是没有建立连接的,会提升从叶子节点回溯的难度 */
        if (!sNode.isLeaf) { loopParent(sNode, disabled); }
        if (sNode.isLeaf || !sNode.children) { loopChild(sNode, disabled); }
      });
      path.pop();
    };

node.children is empty and loopChild will never be executed, so filter will never be executed

@wzhudev
Copy link
Member

wzhudev commented Sep 6, 2018

@zd5043039119 Yes that's a reason.

Since you have found the reason, are you interested in firing a pull request to fix this?

@zd5043039119
Copy link
Contributor Author

sure, i'll try

@lock
Copy link

lock bot commented Sep 17, 2019

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants