pro-components icon indicating copy to clipboard operation
pro-components copied to clipboard

🧐[问题] ModalForm 打开时 onOpenChange 触发两次

Open Icesource opened this issue 1 year ago • 0 comments

🧐 问题描述

使用 open 和 onOpenChange 控制 ModalForm 时,打开ModalForm会触发两次onOpenChange true,关闭时触发一次 false 相似问题 https://github.com/ant-design/pro-components/issues/7545

💻 示例代码

  const _onOpenChange = (open: boolean) => {
    console.log(open);
    setOpen(open);
  }

<ModalForm<any> title={<BaseModalTitle {...titleProps}/>}
                      {...(showEntryDom && {trigger: realEntryDom})}
                      modalProps={{
                        destroyOnClose: true, style: style,
                        afterClose: afterClose
                      }}
                      width={width}
                      open={open}
                      onOpenChange={_onOpenChange}
                      form={form}
                      initialValues={initialValues}
                      labelAlign={"left"}
                      layout={"horizontal"}
                      loading={loading}

                      {...(onFinish && {onFinish: onFinish})}
                      {...layout}
                      submitter={{
                        render: (props, defaultDoms) => {
                          return [
                            <div key={"baseModalSubmitter"}
                                 style={{width: "100%", display: "flex", justifyContent: "space-between"}}>
                              <div>{footer?.left}</div>
                              <div><Space>{
                                FooterRight ? FooterRight : showConfirmButton? defaultDoms: defaultDoms[0]
                              }</Space></div>
                            </div>
                          ]
                        }
                      }}>
        {children}
      </ModalForm>

🚑 其他信息

image

Icesource avatar Feb 05 '24 06:02 Icesource