ant-design / ant-design/pro-components

🐛 [BUG]ProTable使用树结构数据,嵌套子表格式错误

Open
#9,616 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.8k
Forks
1.4k
Avg merge
10h 44m
Merged PRs (30d)
3

Description

### 🐛 bug 描述

ProTable使用树结构数据,嵌套子表,页面错乱,会生成空白tr和td。
即使在expandedRowRender中返回了undefined,也会生成空白表格,页面会有占位。
expandable={{
expandedRowRender: undefined
}}这样写是没问题的

![Image](https://github.com/user-attachments/assets/500deb22-1e4f-48cd-8dff-dcca5d17c082)

### 📷 复现步骤 | Recurrence steps

const subTableRender = (record: Module) => {
if(record.type ==='1'){
return (
{
return await search({...params, pid: record.id, sort: 'desc', filter: 'order_num'});
}
}
pagination={false}
headerTitle={false}
search={false}
options={false}
/>
);
}
return undefined;
}

headerTitle="模块列表"
rowKey="id"
columns={columns}
search={{
labelWidth: 'auto',
}}
actionRef={actionRef}
pagination={{
onChange: (page) => setCurrentPage(page)
}}
request={
async (params: ModuleSearch) => {
return await search({...params, pid: pid, sort: 'desc', filter: 'order_num'});
}
}
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
}
}}
expandable={{
expandedRowRender: subTableRender
}}
toolBarRender={
() => [
{
setShowAdd(true);
}}>
新建

]
}
/>

### 🏞 期望结果 | Expected results

若返回undefined,不应生成dom数据。

### 💻 复现代码 | Recurrence code

### © 版本信息

- Ant Design Pro 版本: [e.g. 4.0.0]
- umi 版本
- 浏览器环境
- 开发环境 [e.g. mac OS]

### 🚑 其他信息

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the provided TypeScript ProTable tree-data example and inspect the expandable-row rendering path. Verify the behavior when expandedRowRender returns undefined; done means no blank tr or td is generated and the nested table still renders correctly for records of type '1'.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.