-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[Tree]: fix #12383 #13349
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 #12383 #13349
Conversation
…isplay wrong:All nodes are fulfilled
Deploy preview for element ready! Built with commit e5bd430 |
调用 doCreateChildren 之后,会调用 insertChild。改变 parent.checked 的那段代码在哪里? |
在 这一行 , 最终会执行到 第 402 行, 当第二个刚好属于defaultChecked 时 会将 parent.checked 设置为true |
@dive2Pro 我看了好久,这样改可行的。但是我觉得有些问题存在。 出现 bug 的原因是:
按照这样的说法,那么 id 为 2 的节点(checked 为 true)刚刚创建时,调用 reInitChecked 方法计算出此父节点的 checked 该为 true 才对。但是在这里 https://jsfiddle.net/8o7gdvhw/ 父元素并没有被选中。 element/packages/tree/src/model/node.js Line 402 in 2437bd4
在一行,你可以加上 console.log(parent.childNodes.length); 查看一下。新的节点刚插入时,childNodes 还未创建。这里的代码好像还存在一些问题。
|
这是因为在第一个 是 defaultChecked 时, 执行 reInitChecked 是 在 element/packages/tree/src/model/node.js Line 233 in fb5d868
element/packages/tree/src/model/node.js Line 25 in fb5d868
执行的判断, 不会将parent.checked 置为 true |
当 前两个child 都为 defaultChecked 时, 第二个 child 才会 在调用到 reInitChecked 时, parent.childNodes 只有一个 checked child , 执行下面 element/packages/tree/src/model/node.js Line 27 in 376f982
返回的 { all }就会为 true 其他的情况, 这里 all 则正常返回 false |
@dive2Pro 嗯,代码没什么问题了。测试用例精简一下就可以合并了。😄 |
大佬们,这个bug什么时候会更新啊 |
* fix: 12383 Tree in lazy mode set child node 'default-checked-keys', display wrong:All nodes are fulfilled * 添加测试 * fix code style * update style
fix #12383
bug 原因:
异步的情况下会执行 doCreateChildren , 如果刚好children 的前两个或多个是 default-checked-keys 中设置的, 那么会将 parent.checked 设置为 true.
在
callback
中 会执行setChecked(true, true)
, 将所有的 children 的 check 的设置为true解决办法:
在 执行 callback 之前, 再次检查该节点的 children.
如果需要的话 可以添加 tests, 但是我碰到有个问题, 在 windows 环境下 测试跑不通