mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(components): [tree-v2] set expanded keys requires multiple nextTick (#20725)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { computed, nextTick, ref, shallowRef, watch } from 'vue'
|
||||
import { computed, ref, shallowRef, watch } from 'vue'
|
||||
import { isObject } from '@element-plus/utils'
|
||||
import {
|
||||
CURRENT_CHANGE,
|
||||
@@ -35,26 +35,6 @@ export function useTree(
|
||||
const tree = shallowRef<Tree | undefined>()
|
||||
const listRef = ref<typeof FixedSizeList | undefined>()
|
||||
|
||||
watch(
|
||||
() => props.currentNodeKey,
|
||||
(key) => {
|
||||
currentKey.value = key
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.data,
|
||||
(data: TreeData) => {
|
||||
setData(data)
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
)
|
||||
|
||||
const {
|
||||
isIndeterminate,
|
||||
isChecked,
|
||||
@@ -288,7 +268,7 @@ export function useTree(
|
||||
}
|
||||
|
||||
function setData(data: TreeData) {
|
||||
nextTick(() => (tree.value = createTree(data)))
|
||||
tree.value = createTree(data)
|
||||
}
|
||||
|
||||
function getNode(data: TreeKey | TreeNodeData) {
|
||||
@@ -307,6 +287,26 @@ export function useTree(
|
||||
listRef.value?.scrollTo(offset)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.currentNodeKey,
|
||||
(key) => {
|
||||
currentKey.value = key
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.data,
|
||||
(data: TreeData) => {
|
||||
setData(data)
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
tree,
|
||||
flattenTree,
|
||||
|
||||
Reference in New Issue
Block a user