Skip to content

Commit 79aeee5

Browse files
authored
fix(EnhancedTable): fix checkAll checkbox status in tree mode (#3988)
1 parent 5a6d3dd commit 79aeee5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/components/table/hooks/useRowSelect.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,16 @@ export default function useRowSelect(
8383

8484
function getSelectedHeader() {
8585
return () => {
86-
const isIndeterminate = intersectionKeys.length > 0 && intersectionKeys.length < canSelectedRows.length;
86+
const isIndeterminate =
87+
// 一些可见的行已被选中,但不是全部
88+
(intersectionKeys.length > 0 && intersectionKeys.length < canSelectedRows.length) ||
89+
// 某些被选中的行不可见(例如折叠的树子节点)
90+
intersectionKeys.length < tSelectedRowKeys.length;
8791
const isChecked =
88-
intersectionKeys.length !== 0 &&
8992
canSelectedRows.length !== 0 &&
90-
intersectionKeys.length === canSelectedRows.length;
93+
intersectionKeys.length === canSelectedRows.length &&
94+
// 确保所有已选中的行都是可见的(没有被折叠而隐藏的选中项)
95+
intersectionKeys.length === tSelectedRowKeys.length;
9196
return (
9297
<Checkbox
9398
checked={isChecked}

0 commit comments

Comments
 (0)