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

Tree:fix Tree懒加载默认选中问题 issue(#21932) #21934

Merged
merged 1 commit into from
Sep 13, 2022

Conversation

kiss-keray
Copy link
Contributor

@kiss-keray kiss-keray commented Jun 18, 2022

问题:

issue(#21932)

bug产生原因:

由于懒加载后doCreateChildren函数使用foreach的方式新增child,每次新增一个child都会执行reInitChecked函数对父节点的选中状态重置。所已第一个child选中后,第二个节点在选中时reInitChecked认为所有子节点(本来有n>2个子节点,只是foreach刚创建2个而已)都选中了,然后导致后面所有新增的child都会因为父节点已选中而被设置为选中。

解决方法:

将节点的loading状态放到doCreateChildren函数完成之后并在reInitChecked计算父节点选中状态时对loading中的节点不处理。等loading完成后由回调函数重新计算父节点的选中状态。

  • Make sure you follow Element's contributing guide (中文 | English | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer relative issues for you PR.

@xinguanhua xinguanhua merged commit bccadfc into ElemeFE:dev Sep 13, 2022
@huang-yaoshi
Copy link

懒加载回显怎么设置呢? 子节点选中 初始回显没有选中状态

@kiss-keray
Copy link
Contributor Author

懒加载回显怎么设置呢? 子节点选中 初始回显没有选中状态

有没有demo看看呢

@kiss-keray
Copy link
Contributor Author

懒加载回显怎么设置呢? 子节点选中 初始回显没有选中状态

default-checked-keys可以设置默认选中的节点,就算是懒加载的子节点也是可以的。

@huang-yaoshi
Copy link

image
这个设置字节点的选中 一级节点没有半选的状态

@huang-yaoshi
Copy link

只有展开了才有选中状态

@kiss-keray
Copy link
Contributor Author

只有展开了才有选中状态

这种的得手动设置父节点的状态,因为在懒加载状态下父节点无法知道子节点的选中了哪些,所已无法自动设置父节点状态。

hzsrc pushed a commit to hzsrc/element that referenced this pull request Feb 2, 2023
@xinguanhua
Copy link
Collaborator

@kiss-keray 你好,我是element-ui官方维护团队的xinguanhua,非常感谢你以pr的方式,为element-ui组件库的完善贡献了一份力量。element-ui有一份礼物将会寄给你,希望能够提供寄件地址及联系方式,可以发送邮件到 xinguanhua@gmail.com

@kiss-keray
Copy link
Contributor Author

@kiss-keray 你好,我是element-ui官方维护团队的xinguanhua,非常感谢你以pr的方式,为element-ui组件库的完善贡献了一份力量。element-ui有一份礼物将会寄给你,希望能够提供寄件地址及联系方式,可以发送邮件到 xinguanhua@gmail.com

邮件已发送

@HuRuilin
Copy link

HuRuilin commented Apr 2, 2024

版本 2.15.14 这个问题还存在呢,不动源码的情况下,有什么规避的小技巧吗

@HuRuilin
Copy link

HuRuilin commented Apr 2, 2024

版本 2.15.14 这个问题还存在呢,不动源码的情况下,有什么规避的小技巧吗
请忽略该问题,该问题在2.15.14 下已修复。谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants