fix: table lazy rows can't expand at the first time (#3731)

* fix: Table Attributes expand-row-keys has changed, but fold not work

* fix: Table lazy column can't expand at the first time

* Update packages/components/table/src/store/tree.ts

Co-authored-by: jeremywu <15975785+JeremyWuuuuu@users.noreply.github.com>

* Update packages/components/table/src/store/tree.ts

Co-authored-by: jeremywu <15975785+JeremyWuuuuu@users.noreply.github.com>

Co-authored-by: jeremywu <15975785+JeremyWuuuuu@users.noreply.github.com>
This commit is contained in:
Alan Wang
2021-10-14 17:38:00 +08:00
committed by GitHub
parent 4cffe3d9e7
commit 39c286f140

View File

@@ -67,6 +67,7 @@ function useTree<T>(watcherData: WatcherPropsData<T>) {
}
const updateTreeData = (
ifChangeExpandRowKeys = false,
ifExpandAll = instance.store?.states.defaultExpandAll.value
) => {
const nested = normalizedData.value
@@ -77,10 +78,17 @@ function useTree<T>(watcherData: WatcherPropsData<T>) {
const oldTreeData = unref(treeData)
const rootLazyRowKeys = []
const getExpanded = (oldValue, key) => {
if (expandRowKeys.value) {
return ifExpandAll || expandRowKeys.value.includes(key)
if (ifChangeExpandRowKeys) {
if (expandRowKeys.value) {
return ifExpandAll || expandRowKeys.value.includes(key)
} else {
return !!(ifExpandAll || oldValue?.expanded)
}
} else {
return !!(ifExpandAll || oldValue?.expanded)
const included =
ifExpandAll ||
(expandRowKeys.value && expandRowKeys.value.includes(key))
return !!(oldValue?.expanded || included)
}
}
// 合并 expanded 与 display确保数据刷新后状态不变
@@ -126,6 +134,13 @@ function useTree<T>(watcherData: WatcherPropsData<T>) {
instance.store?.updateTableScrollY()
}
watch(
() => expandRowKeys.value,
() => {
updateTreeData(true)
}
)
watch(
() => normalizedData.value,
() => {