ant-design / ant-design/pro-components

🐛[BUG]在Schema Form中使用'表单集合'(valueType=’formSet‘)时,父组件与子组件的initialValue没有同步赋值

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

### 🐛 bug 描述

在Schema Form中使用'表单集合'(valueType=’formSet‘)时,如果给父组件设置了initialValue,并给其下的子组件设置为必填,虽然在页面呈现上所有子组件均已填入内容,但直接提交会提示所有子组件为空;同样的,如果只给所有子组件设置initialValue,在不修改内容的前提下提交表单,在onFinish里观察到父组件并没有赋值。

### 📷 复现步骤

[codesandbox](https://codesandbox.io/p/sandbox/schema-biao-dan-forked-7jpdcr)

### 🏞 期望结果

formSet中的父组件与子组件的initialValue能双向同步

### 💻 复现代码

[codesandbox](https://codesandbox.io/p/sandbox/schema-biao-dan-forked-7jpdcr)

### © 版本信息

- ProComponents 版本: 2.6.50
- 浏览器环境 Chrome 124.0.6367.63
- 开发环境 Windows 11

### 🚑 其他信息

![图片](https://github.com/ant-design/pro-components/assets/2436252/56e91ff4-f589-4e7e-9310-125d0d6875f2)

Contributor guide

Open the contributing guide

Research direction

Start by running the linked CodeSandbox reproduction for Schema Form with valueType='formSet', then inspect the formSet handling and its initialValue behavior. Verify the fix by checking that parent and child initial values stay synchronized and that submission no longer reports required children as empty or omits the parent value in onFinish.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.