ant-design / ant-design/pro-components

🐛[BUG] ProFormDigit 非必填时,没有填值时提交的数据缺少该字段

Open
#8,044 5 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 描述
ProFormDigit 非必填时,validateFields,onValuesChange,onFinish中返回的值缺少该字段

### 📷 复现步骤

1. 清空输入框值,点击提交按钮,查看输出
![image](https://github.com/ant-design/pro-components/assets/6482819/58928d23-566c-4628-b6dc-af8507d9da83)

2. 填写1,再点击提交按钮,查看输出
![image](https://github.com/ant-design/pro-components/assets/6482819/1cd01f86-13b0-40cb-8618-33b504579668)

### 🏞 期望结果
1. 清空输入框值,点击提交按钮,输出结果应该是
`{ price:null }`
与ant form.item InputNumber 对齐
https://stackblitz.com/edit/react-s4h9ap?file=demo.tsx

### 💻 复现代码

https://stackblitz.com/edit/react-abklup?file=App.tsx

### © 版本信息

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

### 🚑 其他信息

Contributor guide

Open the contributing guide

Research direction

Start with the App.tsx reproduction linked in the issue and compare ProFormDigit with Ant Design Form.Item using InputNumber. Trace the values returned by validateFields, onValuesChange, and onFinish when the field is cleared. Done means an optional empty ProFormDigit consistently returns { price: null } like InputNumber.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.