如何在单击确认反应谱 ModalTrigger 时关闭对话框?
我有一个对话框,我正在使用来自反应谱(旧版本)的 ModalTrigger。该对话框有两个按钮,“确定”和“取消”。取消时无需执行任何操作,但应在单击“确定”时触发操作,对话框应关闭并启动操作。我能够启动操作,但对话框未关闭。
代码:
<ModalTrigger>
<Button label="Do something" variant="action"></Button>
<Dialog
confirmLabel="Confirm"
cancelLabel="Cancel"
mode="confirmation"
onConfirm={props.confirmAction}
keyboardConfirm="true"
backdropClickable={true}>
{title}
</Dialog>
</ModalTrigger>
当用户单击 onConfirm 然后启动 props.confirmAction 时,如何关闭对话框按钮?到目前为止,对话框在 props.confirmAction 完成之前不会关闭。
I have a dialog box which I am using from ModalTrigger from react spectrum(old version). The dialog box has two buttons, Okay and Cancel.Nothing to do on cancel, but the action should be triggered on clicking of Okay, the dialog box should close and action should initiate. I am able to initiate action but dialog box is not closing.
Code:
<ModalTrigger>
<Button label="Do something" variant="action"></Button>
<Dialog
confirmLabel="Confirm"
cancelLabel="Cancel"
mode="confirmation"
onConfirm={props.confirmAction}
keyboardConfirm="true"
backdropClickable={true}>
{title}
</Dialog>
</ModalTrigger>
How can I close the dialog button when user clicks onConfirm and then start props.confirmAction?As of now, the dialog box don't close until props.confirmAction completes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们可以通过两种方式实现它。
dialog.dismiss
,然后触发props。 verifyAction
onDismiss
而不是onConfirm
We can achieve it in 2 ways.
dialog.dismiss
followed byprops. confirmAction
onDismiss
instead ofonConfirm