ant-design / ant-design/pro-components

🐛[BUG]自定义valuetype时候 request fieldProps 等关键词无法通过fieldProps传递到组件里面来

Open
#8,621 0 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

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

### 🐛 bug 描述

自定义valuetype时候 request fieldProps 等关键词无法通过fieldProps传递到组件里面来
![image](https://github.com/user-attachments/assets/38f5d2f2-eca9-4f3c-a035-0bb771f794a3)
![image](https://github.com/user-attachments/assets/751394a9-6b94-418f-becf-014f010ab789)
![image](https://github.com/user-attachments/assets/cf1047e6-07cc-4673-9fd7-b1aa3ab4b183)

### 📷 复现步骤

1. 将ProFromTreeSelect定义为自定义valuetype
![image](https://github.com/user-attachments/assets/27ef486d-f91f-4908-b77b-741d7cadb156)

2. 在column schema
![image](https://github.com/user-attachments/assets/751394a9-6b94-418f-becf-014f010ab789)

3. 打印valuetype里面的props无法拿到request方法,换成其他名字比如api就能拿到
![image](https://github.com/user-attachments/assets/cf1047e6-07cc-4673-9fd7-b1aa3ab4b183)

### 🏞 期望结果

### 💻 复现代码

```tsx
// 自定义valuetype代码

/**
* 自定义 valueMap
*/
export const valueTypeMap: Record = {
proTreeSelect: {
renderFormItem(text, props) {
console.log(text);
console.log(props);
// request fieldProps 等参数无法传过来
return (

);
},
},
};
```
```tsx
// column schema
{
title: '上级ID',
dataIndex: 'pid',
width: 300,
valueType: 'proTreeSelect',
fieldProps: () => {
return {
// hell: () => {},
request: (v: any) => {
return new Promise((resolve, reject) => {
all_permission(v)
.then((ret) => {
resolve(to_tree(ret.data, ''));
})
.catch((e) => reject(e));
});
},
tree: {
fieldNames: {
label: 'name',
value: 'id',
},
},
};
},
}
```
### © 版本信息

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

### 🚑 其他信息

Contributor guide

Open the contributing guide

Research direction

No repository file or test is named. Reproduce the issue from the custom valueType's renderFormItem and the ProFormTreeSelect column schema, then trace how fieldProps are passed into the component. Done means the request callback and nested tree fieldNames arrive through the documented fieldProps path, with a regression test covering the schema.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.