We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用 open 和 onOpenChange 控制 ModalForm 时,打开ModalForm会触发两次onOpenChange true,关闭时触发一次 false 相似问题 #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>
The text was updated successfully, but these errors were encountered:
应该是同时使用了 open 和 trigger 来控制弹窗的开关,在第一次触发 onOpenChange 的时候,去 setOpen,然后改了 open,有触发了第二次 onOpenChange
Sorry, something went wrong.
在 onOpenChange 里加个判断前后 open 是否一致,不一致就执行逻辑,这样可以暂时解决执行两次的问题。
const [open, setOpen] = useState(false); ... const onOpenChange = (isOpen: boolean) => { setOpen(isOpen); if (isOpen && !open) { // 弹窗打开时需要执行的逻辑 .... } }
Successfully merging a pull request may close this issue.
🧐 问题描述
使用 open 和 onOpenChange 控制 ModalForm 时,打开ModalForm会触发两次onOpenChange true,关闭时触发一次 false
相似问题 #7545
💻 示例代码
🚑 其他信息
The text was updated successfully, but these errors were encountered: