-
-
Notifications
You must be signed in to change notification settings - Fork 17.3k
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
fix(components): [tree] highlight the corresponding node after data reset #18578
Conversation
👋 @momei-LJM, thank you for contributing element-plus. |
Hello @momei-LJM, thank you for contributing to element-plus, please see our guideline to see how to make contribution |
commit: |
🧪 Playground Preview: https://element-plus.run/?pr=18578 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test case?
@momei-LJM Can you add this code to data() {
return {
+ currentId: null, test('update tree-data after current-node-key', async () => {
const { wrapper, vm } = getTreeVm(
`:props="defaultProps" :expand-on-click-node="false" default-expand-all highlight-current node-key="id" :current-node-key="currentId"`
)
vm.currentId = 22
await nextTick()
const currentNodeLabelWrapper = wrapper.find(
'.is-current .el-tree-node__label'
)
expect(wrapper.find('.el-tree--highlight-current').exists()).toBe(true)
expect(currentNodeLabelWrapper.text()).toEqual('二级 2-2')
const _data = [...vm.data]
await nextTick()
vm.data = [..._data]
await nextTick()
const currentNodeLabelWrapper2 = wrapper.find(
'.is-current .el-tree-node__label'
)
expect(currentNodeLabelWrapper2.exists()).toBe(true)
expect(currentNodeLabelWrapper2.text()).toEqual('二级 2-2')
expect(wrapper.find('.el-tree--highlight-current').exists()).toBe(true)
}) |
added |
done |
fix #18576