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

When tree is loaded asynchronously, the loaded-keys node will not be refreshed. Version 2.2.8 can #4835

Closed
1 task done
wzohxia opened this issue Nov 2, 2021 · 5 comments
Labels

Comments

@wzohxia
Copy link

wzohxia commented Nov 2, 2021

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

Version

3.0.0-alpha.6

Environment

vue 3.2.16

Reproduction link

https://next.antdv.com/components/tree-cn

Steps to reproduce

<template>
<a-tree
v-model:selectedKeys="selectedKeys"
v-model:expandedKeys="expandedKeys"
:loaded-keys="loadKeys"
:load-data="onLoadData"
:tree-data="treeData"
/>
<a-button @click="test">测试刷新</a-button>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue'
import type { TreeProps } from 'ant-design-vue'
export default defineComponent({
setup() {
const loadKeys = ref<string[]>([])
const expandedKeys = ref<string[]>([])
const selectedKeys = ref<string[]>([])
const treeData = ref<TreeProps['treeData']>([
{ title: 'Expand to load', key: '0' },
{ title: 'Expand to load', key: '1' },
{ title: 'Tree Node', key: '2', isLeaf: true },
])
const onLoadData = (treeNode: any) => {
loadKeys.value.push(treeNode.eventKey)
return new Promise((resolve: (value?: unknown) => void) => {
setTimeout(() => {
treeNode.dataRef.children = [
{
title: 'Child Node'   Math.floor(Math.random() * 100   1),
key: `${treeNode.eventKey}-0`,
},
{ title: 'Child Node', key: `${treeNode.eventKey}-1` },
]
treeData.value = [...treeData.value]
resolve()
}, 1)
})
}

const test = () => {
treeData.value[0].children = []
loadKeys.value = []
}
return {
loadKeys,
expandedKeys,
selectedKeys,
treeData,
onLoadData,
test,
}
},
})
</script>

1.打开第一个节点
2.点击测试刷新
3.在2.2.8版本时会刷新子节点, 3.0.0-alpha.8 版本时子节点清空且不会刷新子节点

What is expected?

能刷新子节点

What is actually happening?

子节点不会刷新

@github-actions github-actions bot changed the title tree 异步加载时 控制loaded-keys 节点不会刷新 2.2.8版本可以 When tree is loaded asynchronously, the loaded-keys node will not be refreshed. Version 2.2.8 can Nov 2, 2021
@wzohxia
Copy link
Author

wzohxia commented Nov 2, 2021

https://codesandbox.io/s/vue-antd-template-forked-no2z9 切换2.2.8时正常

@tangjinzhou
Copy link
Member

感觉2.2.8反而是有问题的 你可以参考这个
https://codesandbox.io/s/vue-antd-template-forked-cbiin?file=/src/App.vue

@wzohxia
Copy link
Author

wzohxia commented Nov 3, 2021

感觉2.2.8反而是有问题的 你可以参考这个 https://codesandbox.io/s/vue-antd-template-forked-cbiin?file=/src/App.vue

这样第一个节点打开后,再打开下面的子节点。 然后点击刷新,下面的打开过的子节点就出问题了
刷新前:
image
刷新后:
image

@wzohxia
Copy link
Author

wzohxia commented Nov 3, 2021

感觉2.2.8反而是有问题的 你可以参考这个 https://codesandbox.io/s/vue-antd-template-forked-cbiin?file=/src/App.vue

https://codesandbox.io/s/upbeat-curie-ig4pe?file=/src/App.vue 这个里面加了一个测试展开 通过控制expandedKeys来展开 导致数据不会加载 一样是2.2.8生效的 出现问题的原因 应该跟上面的是一样的

@github-actions
Copy link

github-actions bot commented Nov 6, 2022

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 Nov 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants