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

nz-tree中首次设置[nzExpandAll]="true"展开,但nzData变动后不展开 #5446

Closed
peacejj opened this issue Jun 17, 2020 · 6 comments · Fixed by #6161
Closed

nz-tree中首次设置[nzExpandAll]="true"展开,但nzData变动后不展开 #5446

peacejj opened this issue Jun 17, 2020 · 6 comments · Fixed by #6161

Comments

@peacejj
Copy link

peacejj commented Jun 17, 2020

Reproduction link

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

Steps to reproduce

我设置了一个定时器,5s后更新nzData值,树形结构收缩,没有展开

What is expected?

希望一直是展开状态

What is actually happening?

现在是收缩了

Environment Info
ng-zorro-antd 9.2.0
Browser Version 83.0.4103.97 (Official Build) (64-bit)
@zorro-bot
Copy link

zorro-bot bot commented Jun 17, 2020

Translation of this issue:

nz-tree was first set [nzExpandAll] = "true" start, but does not change after the commencement of nzData

Reproduction link

[Https://stackblitz.com/edit/angular-q7lmud?file=src/app/app.component.ts](https://stackblitz.com/edit/angular-q7lmud?file=src/app/app. component.ts)

Steps to reproduce

I set a timer, update nzData value 5s, tree contraction, not expansion

What is expected?

Hope has been expanded state

What is actually happening?

It is contracted

Environment Info
Ng-zorro-antd 9.2.0
Browser Version 83.0.4103.97 (Official Build) (64-bit)

@peacejj
Copy link
Author

peacejj commented Jun 18, 2020

@simplejason 您好,这个问题定为bug了,现在没有解决的方法是嘛?

@yzhe554
Copy link

yzhe554 commented Jun 18, 2020

似乎问题是每次input改变expandAll都会被设置成false.

let expandAll = false;

一个naive的解法就是把expandAll 变成component的local member这样状态就记住了。同时ngOnChanges也保证了第一次expandAll的设值顺序。

@peacejj
Copy link
Author

peacejj commented Jun 22, 2020

@yzhe554 您好 expandAll 设置为本地变量,在nzData变更时,还是会收缩。您提到的ngOnChanges我并没有使用,而是直接重置了nzData,和这个有关联嘛?

@yzhe554
Copy link

yzhe554 commented Jun 23, 2020

Hi @peacejj,你是说你更改tree.component.ts之后还是有问题么?我并没有试过,不过从代码看是tree component的一个bug。任何input变化都会让expandAll重置成false

@w6942
Copy link

w6942 commented Jun 30, 2020

nzCollapsed也有类似的问题

@hsuanxyz hsuanxyz added this to the backlog milestone Oct 23, 2020
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Dec 8, 2020
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Dec 8, 2020
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Dec 8, 2020
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Dec 8, 2020
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Dec 8, 2020
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Dec 8, 2020
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Dec 8, 2020
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Dec 9, 2020
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Dec 14, 2020
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Dec 16, 2020
hsuanxyz added a commit that referenced this issue Dec 16, 2020
close #5976, close #5809, close #5739, close #5736, close #5519, close #5446, close #5152, close #4694, close #4472, close #3832, close #2785, close #2744, close #6199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants