mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
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:
@@ -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,
|
||||
() => {
|
||||
|
||||
Reference in New Issue
Block a user