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

TreeSelect nzCheckable and nzCheckStrictly causes parent node to be removed when only child node is clicked #5068

Closed
atom-morgan opened this issue Apr 17, 2020 · 2 comments

Comments

@atom-morgan
Copy link

Reproduction link

https://stackblitz.com/edit/angular-ogz5wh?file=src/app/app.component.ts

Steps to reproduce

  1. Click nodes parent 1-0, leaf 1-0-0, and leaf 1-0-1.
  2. Click to remove node leaf 1-0-0.

Only node leaf 1-0-0 is removed from the list.

Update the template code to what's below which adds nzCheckable.

<nz-tree-select
  style="width: 250px"
  nzPlaceHolder="Please select"
  [(ngModel)]="value"
  [nzMaxTagCount]="3"
  [nzMaxTagPlaceholder]="omittedPlaceHolder"
  [nzNodes]="nodes"
  [nzDefaultExpandAll]="true"
  [nzAllowClear]="false"
  [nzMultiple]="true"
  [nzCheckStrictly]="true"
  [nzCheckable]="true"
  (ngModelChange)="onChange($event)"
  >
</nz-tree-select>
  1. Click nodes parent 1-0, leaf 1-0-0, and leaf 1-0-1.
  2. Click to remove node leaf 1-0-0.

Nodes parent 1-0 and leaf 1-0-0 are both removed from the list.

What is expected?

Only leaf 1-0-0 should be removed from the list

What is actually happening?

Nodes parent 1-0 and leaf 1-0-0 are both removed from the list.

Environment Info
ng-zorro-antd 9.0.0
Browser Chrome 80.0.3987.163

If I understand the documentation correctly, nzCheckable should simply add checkboxes to the TreeSelect and nzCheckStrictly should remove any associations between parent nodes and child nodes but using these two together doesn't seem to work correctly.

@vthinkxie
Copy link
Member

vthinkxie commented Apr 20, 2020

Hi @atom-morgan
I have tried to replace the template as you described, but everything works fine as the expected.
https://stackblitz.com/edit/angular-ogz5wh-qipucw?file=src/app/app.component.ts

@atom-morgan
Copy link
Author

Hi @vthinkxie, I just tried this again and I'm still getting the same results. I've included a gif of the behavior that I'm seeing.

ant-tree

hsuanxyz pushed a commit to hsuanxyz/ng-zorro-antd that referenced this issue Aug 5, 2020
…O#5431)

* fix(module: tree): fix nzCheckStrictly and selected keys bug

* fix(module: tree-select): fix wrong rendering with nzCheckable

* fix(module: tree-select): fix unnecessary codes

* fix(module: tree-select): fix node selection with nzCheckStrictly

close NG-ZORRO#5385, close NG-ZORRO#5195, close NG-ZORRO#5068
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants