ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.04k stars 1.29k forks source link

🐛[BUG] ModalForm 使用 request 请求数据 如果传入 form 实例 request 返回的最新数据无法实时填充到 form,展示的还是上一次的值 #7925

Closed Gzbox closed 4 months ago

Gzbox commented 5 months ago
"@ant-design/pro-components": "2.6.43",
"@umijs/max": "4.0.86",
"antd": "5.8.3",
  const [form] = Form.useForm();

  <ModalForm
      form={form}
      open={dslModalVisible}
      modalProps={{
        bodyStyle: {
          maxHeight: '70vh',
        },
        destroyOnClose: true,
      }}
      params={{...xxxx}}
      request={async (params) => {
        const resp = await getxxxxxxxxxApi(params);
        if (resp?.resp_code === 0) {
          return {
            ...resp?.data,
            dsl: resp?.data?.dsl || undefined,
          };
        }
        return {
          dsl: undefined
        };
      }}
    >
      <Form.Item name="dsl" style={{ width: '100%' }}>
        <Input  />
      </Form.Item>
    </ModalForm>

如果去掉 form={form} 表现符合预期 如何加上了 表单结果填充的就不对 是上一次请求的结果 实际请求接口已经返回了最新的

foureyeschao commented 4 months ago

同样的问题,求解决

chenshuai2144 commented 4 months ago

每次 ModalForm 关闭的时候销毁一下的 Modal

leadingtw273 commented 3 months ago

所以是指定 form Ref 的狀況下 destroyOnClose 就會失效嗎~?

codedart2018 commented 2 weeks ago

这bug为什么关闭了呢。现在我也严重遇到这个问题了!

codedart2018 commented 2 weeks ago

不止 ModalForm DrawerForm 同样问题!

codedart2018 commented 2 weeks ago

每次 ModalForm 关闭的时候销毁一下的 Modal

销毁也没有用,只要挂载form ref就会存在数据回显问题,查dom元素已经消失了,但数据回显还是有问题的!只是dom结构在变,但渲染的数据是有问题的