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] v2.7.1 ModalForm 的 onOpenChange 打开时无法触发 #8330

Open hihuangwei opened 3 weeks ago

hihuangwei commented 3 weeks ago

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🐛 bug 描述

v2.7.1 ModalForm 的 onOpenChange 打开时无法触发

zhuba-Ahhh commented 3 weeks ago

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🐛 bug 描述

v2.7.1 ModalForm 的 onOpenChange 打开时无法触发

可以给下简化的使用代码嘛,v2.7.1调整为onOpenChange 只有当传入的open改变时触发,意思是初始是不会触发的

hihuangwei commented 3 weeks ago

提问前先看看: https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🐛 bug 描述

v2.7.1 ModalForm 的 onOpenChange 打开时无法触发

可以给下简化的使用代码嘛,v2.7.1调整为onOpenChange 只有当传入的open改变时触发,意思是初始是不会触发的

<ModalForm
      form={form}
      title={formatMessage({ id: 'user.account.edit' })}
      open={modalOpen.show}
      preserve={false}
      onOpenChange={(open) => {
        if (open) {
          setLoading(true);
          edit(modalOpen.id)
            .then((res) => {
              if (res && res.code === 0) {
                setMetaRoles(res.meta.roles);
                setMetaGroups(res.meta.groups);
                setMetaStatus(res.meta.status);
                setMetaGenders(res.meta.genders);
                setEditData({ ...res.data, success: true });
                form.setFieldsValue(res.data);
              }
            })
            .finally(() => {
              setLoading(false);
            });
        }
      }}
      submitter={!loading && editData.success ? {} : false}
      modalProps={{ ...modalLayout, onCancel }}
      onFinish={async (values) => {
        const res = await update(editData.id, { ...values });
        if (res && res.code === 0) {
          message.success('修改成功');
          submitForm();
        }
      }}
    >
      {loading ? <ProLoading /> : editData.success ? <EditForm /> : <ProEmpty />}
    </ModalForm>
hihuangwei commented 2 weeks ago

https://github.com/ant-design/pro-components/commit/f12ef2ba4252122210b1242ca3552c8f3730c944 回退到这吧

leshalv commented 1 week ago

+1