Skip to content

Conversation

@donaldshen
Copy link
Contributor

Why

原本的 updateCheckedKeys 有个诡异的过滤父节点的操作,导致 checkedKeys 中的父节点都没了。猜测:

  • 据称原意是为了防止 check 父节点时把其下所有子节点都 check 了;但这应该是由 el-tree 的 check-strictly 来控制的表现。
  • 可能当时的 el-tree 还没有 check-strictly 这个属性吧

How

  1. stylus => less
  2. eslint --fix
  3. 移除 updateCheckedKeys 中自作主张的代码
  4. 更新 show-checkbox.md,详细讲解不同 check-strictly 设置下 checkedKeys 的不同表现

Test

以 show-checkbox 的示例为例:

{
  checkedKeys: [
    92016, // 某子节点。checkStrictly 为 true 时不影响父节点;为 false 时父节点为半选状态
    92018, // 某子节点。同上
    92023, // 某父节点。checkStrictly 为 true 时不影响子节点;为 false 时子节点全被选中
  ]
}

Before

image

After

image
image

Docs

show-checkbox 示例给更多的注释说明
image

@auto-add-label auto-add-label bot added the bug Something isn't working label Jan 8, 2020
@netlify
Copy link

netlify bot commented Jan 9, 2020

Deploy preview for el-data-tree ready!

Built with commit 746151a

https://deploy-preview-62--el-data-tree.netlify.com

* @public
*/
updateCheckedKeys(keys) {
//设置checkedKeys的时候,设置父节点,子节点全部也被选中了
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在非 checkStrickly 的时候,只选中子节点,但后端post/put接口需要传 父节点,而 get 请求时会返回 父节点数据,则需要用到这断代码把父节点过滤掉

@levy9527 levy9527 added the question Further information is requested label Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants