From 0be283e0f9ac607884dc13f1382c90cc483869f5 Mon Sep 17 00:00:00 2001 From: sheepluo Date: Sun, 25 Feb 2024 14:16:54 +0800 Subject: [PATCH] fix: treeTable can not expand properly after folding all nodes (#1729) * fix: Table fold all * chore: remove console --------- Co-authored-by: sheepluo --- js/table/tree-store.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/table/tree-store.ts b/js/table/tree-store.ts index f324e1c97e..13b1a475c0 100644 --- a/js/table/tree-store.ts +++ b/js/table/tree-store.ts @@ -577,15 +577,17 @@ class TableTreeStore { */ foldAll(dataSource: T[], keys: KeysType) { const newData: T[] = []; + let index = 0; for (let i = 0, len = dataSource.length; i < len; i++) { const item = dataSource[i]; const rowValue = get(item, keys.rowKey); const state = this.treeDataMap.get(rowValue); - state.rowIndex = state.level === 0 ? i : -1; + state.rowIndex = state.level === 0 ? index : -1; state.expanded = false; state.expandChildrenLength = 0; if (state.level === 0) { newData.push(item); + index += 1; } const children = get(item, keys.childrenKey); if (children?.length) {