ant-design / ant-design/pro-components
🧐[问题] 树形结构下,使用rowSelection功能使用,在toolBarRender中,rows不能获取到子节点
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 1.4k
- Avg merge
- 10h 44m
- Merged PRs (30d)
- 3
Description
### 🧐 问题描述
树形结构下,使用rowSelection功能使用,在toolBarRender中,rows不能获取到子节点
### 💻 示例代码
### 🚑 其他信息
看了源码,是这样实现的,没有遍历children
```
const getRowKey = React.useMemo>(() => {
if (typeof rowKey === 'function') {
return rowKey;
}
return (record: T, index?: number) => {
if (index === -1) {
return (record as any)?.[rowKey as string];
}
// 如果 props 中有name 的话,用index 来做行号,这样方便转化为 index
if (props.name) {
return index?.toString();
}
return (record as any)?.[rowKey as string] ?? index?.toString();
};
}, [props.name, rowKey]);
useMemo(() => {
if (action.dataSource?.length) {
const keys = action.dataSource.map((data) => {
const dataRowKey = getRowKey(data, -1);
preserveRecordsRef.current.set(dataRowKey, data);
return dataRowKey;
});
return keys;
}
return [];
}, [action.dataSource, getRowKey]);
```
Contributor guide
Research direction
Start from the row-key and preserve-record logic shown in the issue, then inspect how tree-shaped data is handled for rowSelection and toolBarRender. Reproduce the problem with nested data and verify that rows includes selected child nodes; add or update a regression test if the repository has one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100