ant-design / ant-design/pro-components
🐛[BUG] BetaSchemaForm 使用 Modal LayoutType 时,destroyOnClose:true 关闭重置行为和普通的 ModalForm 不一致
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 1.4k
- Avg merge
- 10h 44m
- Merged PRs (30d)
- 3
Description
### 🐛 bug 描述
BetaSchemaForm 中使用了 `useForm` 进行 formInstance 的创建并传递给底层的 Form 组件。[详见此处](https://github.com/ant-design/pro-components/blob/master/packages/form/src/components/SchemaForm/index.tsx#L71)
会导致配置 `destroyOnClose:true` 时无法正确销毁 form。导致与直接使用 ModalForm 行为存在差异
### 📷 复现步骤
请参考此 codesandbox
https://codesandbox.io/s/prod-lake-5g9g9n?file=/src/App.js
其中第一个按钮。直接使用 ModalForm 行为正常。无论第几次点击。通过 message 打印出的的表单数据均和表单实际数据一致。
而第二个按钮(BetaSchemaForm)和第三个按钮(ModalForm + useForm控制 instance) 第一次打开数据正确。第二次之后的打开。数据回写为上一次(T-1)数据
### 🏞 期望结果
BetaSchemaForm 的行为和 单独使用 ModalForm 一致
### 💻 复现代码
https://codesandbox.io/s/prod-lake-5g9g9n
### © 版本信息
- ProComponents 版本: 2.6.34
Contributor guide
Research direction
Start with packages/form/src/components/SchemaForm/index.tsx around line 71, where useForm creates the formInstance passed to the underlying Form. Run the linked CodeSandbox and compare BetaSchemaForm with ModalForm using destroyOnClose:true, including the useForm-controlled case. Done means reopening the BetaSchemaForm produces current form data consistently with ModalForm.
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