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

The default selection data of the tree under checkstrict is a one-dimensional array, but once clicked, it becomes a two-dimensional array of checked: and halfchecked #5395

Closed
1 task
yemaozi999 opened this issue Mar 24, 2022 · 9 comments
Labels
🤔 Need Reproduce We cannot reproduce your problem outdated

Comments

@yemaozi999
Copy link

yemaozi999 commented Mar 24, 2022

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.1.0-rc.2

Environment

chrome

Reproduction link

[https://www.undefinded.com](https://codesandbox.io/s/f0w5es?file=/src/App.vue)

Steps to reproduce

checkStrictly 下的tree 默认选择数据是 一维数组[1,2,3], 但是一点击 就变成 checked:[1,2,3] 和 halfChecked:[] 的二维数组,
我一开始传 二维数组, 整个tree 都点不了了

What is expected?

传入的数据是一维, 点击后的动态数据 一维, 或者 传入的二维 点击也是二维
The incoming data is one-dimensional, the dynamic data after clicking is one-dimensional, or the incoming two-dimensional click is also two-dimensional

What is actually happening?

checkStrictly 下的tree 默认选择数据是 一维数组, 但是一点击 就变成 checked: 和 halfChecked 的二维数组,
我一开始传 二维数组, 整个tree 都点不了了

The default selection data of the tree under checkstrict is a one-dimensional array, but once clicked, it becomes a two-dimensional array of checked: and halfchecked,When I first passed the two-dimensional array, the whole tree couldn't be clicked

@tangjinzhou tangjinzhou added the 🤔 Need Reproduce We cannot reproduce your problem label Mar 24, 2022
@github-actions
Copy link

Hello @yemaozi999. Please provide a online reproduction by forking this link for vue2link for vue3 or a minimal GitHub repository. Make sure to choose the correct version.

你好 @yemaozi999, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 for vue2此处 for vue3 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。请确保选择准确的版本。

@tangjinzhou
Copy link
Member

不是二维数组。是类似这种:
const checkedKeys = ref({ checked: ['0-0-0', '0-0-1'], halfChecked: [] });

@yemaozi999
Copy link
Author

@yemaozi999
Copy link
Author

yemaozi999 commented Mar 25, 2022

这样数据格式变化, 会出现处理的问题, 要写两种方法来区分 初始数据 和点击数据
const menuIds = ref<number[]>([])

const checkshow = (id:number)=>{
if(typeof menuIds.value['checked']!='undefined'){ //判断点击后的数据
if(menuIds.value['checked'].includes(id)){
return true;
}
}else{
if(menuIds.value.includes(id)){ //判断点击前的数据
return true;
}
}
return false;
}

@yemaozi999
Copy link
Author

而且在checkStrictly 模式下, 无论怎么点 halfChecked 数组都不会有值

@tangjinzhou
Copy link
Member

tangjinzhou commented Mar 28, 2022

checkStrictly 下传单数组没来就是错误的,只是组件做了容错处理。
checkStrictly 下 halfChecked 要手动控制,因为你不可能点击出半选啊

@github-actions
Copy link

github-actions bot commented Apr 5, 2022

Since the issue was labeled with Need Reproduce, but no response in 7 days. This issue will be closed. If you have any questions, you can comment and reply.

由于该 issue 被标记为需要复现信息,却 7 天未收到回应。现关闭 issue,若有任何问题,可评论回复。

@FrozenJun
Copy link

FrozenJun commented Apr 14, 2022

checkStrictly为false的情况下,onCheck回调没有返回halfChecked的值,只是返回checked值的数组,但组件当前的状态是父子节点选中状态存在关联。
当checkStrictly为true时,onCheck会返回带halfChecked的对象,但此时父子节点没有关联,所以halfChecked永远是空数组。
所以是不是onCheck回调的形参在checkStrictly不同情况下传反了?

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤔 Need Reproduce We cannot reproduce your problem outdated
Projects
None yet
Development

No branches or pull requests

3 participants