Tree:fix Tree懒加载默认选中问题 issue(#21932) - #21934
Merged
Merged
Conversation
|
懒加载回显怎么设置呢? 子节点选中 初始回显没有选中状态 |
Contributor
Author
有没有demo看看呢 |
Contributor
Author
default-checked-keys可以设置默认选中的节点,就算是懒加载的子节点也是可以的。 |
|
只有展开了才有选中状态 |
Contributor
Author
这种的得手动设置父节点的状态,因为在懒加载状态下父节点无法知道子节点的选中了哪些,所已无法自动设置父节点状态。 |
hzsrc
pushed a commit
to hzsrc/element
that referenced
this pull request
Feb 2, 2023
Collaborator
|
@kiss-keray 你好,我是element-ui官方维护团队的xinguanhua,非常感谢你以pr的方式,为element-ui组件库的完善贡献了一份力量。element-ui有一份礼物将会寄给你,希望能够提供寄件地址及联系方式,可以发送邮件到 xinguanhua@gmail.com。 |
Contributor
Author
邮件已发送 |
|
版本 2.15.14 这个问题还存在呢,不动源码的情况下,有什么规避的小技巧吗 |
|
This was referenced May 19, 2024
This was referenced May 25, 2024
This was referenced Sep 19, 2024
This was referenced Sep 25, 2024
This was referenced Sep 27, 2024
This was referenced Sep 29, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

问题:
issue(#21932)
bug产生原因:
由于懒加载后doCreateChildren函数使用foreach的方式新增child,每次新增一个child都会执行reInitChecked函数对父节点的选中状态重置。所已第一个child选中后,第二个节点在选中时reInitChecked认为所有子节点(本来有n>2个子节点,只是foreach刚创建2个而已)都选中了,然后导致后面所有新增的child都会因为父节点已选中而被设置为选中。
解决方法:
将节点的loading状态放到doCreateChildren函数完成之后并在reInitChecked计算父节点选中状态时对loading中的节点不处理。等loading完成后由回调函数重新计算父节点的选中状态。
devbranch.