Tencent / Tencent/tdesign-react
[Form]form里<Select valueType="object" />通过form.setFieldsValue()方式赋值,传{label,value}无法赋值进去
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 965
- Forks
- 373
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 17
Description
重现链接
https://stackblitz.com/edit/w6mqz2y6?file=src%2Fdemo.tsx
重现步骤
点击链接里的"设置数据"按钮,可以看到select2没赋值进去
期望结果
传{select2:{label:'1',value:1}}能正常赋值成功
实际结果
发现只有像select3这样传[{label:'1',value:1}]才能正常赋值
补充说明
手动选select2下拉里的值时,输出是{label:'1',value:1},希望通过setFieldsValue设置也能是相同格式,而不是额外改成array才能赋值进去
| Environment | Info |
|---|---|
| 相关版本 | 1.12.3 |
| 框架版本 / 基础库版本 | react 18.2.0 |
| 系统、浏览器 | Chrome |
| Node版本 |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked StackBlitz reproduction and inspect the Form and Select handling for valueType="object". Verify the setFieldsValue path using {label: '1', value: 1} against the manual selection behavior. Done means select2 accepts the object directly and matches the expected displayed and submitted value without converting it to an array.
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