From ebbb13f16303adcb440519dba28ad06c36b93d6a Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 23 Apr 2024 11:27:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(pop-confirm):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E7=A1=AE=E5=AE=9A=E6=8C=89=E9=92=AE=E8=A7=A6?= =?UTF-8?q?=E5=8F=91onCancel=E9=97=AE=E9=A2=98(#2810)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/pop-confirm/src/use-pop-confirm.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/ui/pop-confirm/src/use-pop-confirm.ts b/packages/ui/pop-confirm/src/use-pop-confirm.ts index 272ae49fa..1a28cd324 100644 --- a/packages/ui/pop-confirm/src/use-pop-confirm.ts +++ b/packages/ui/pop-confirm/src/use-pop-confirm.ts @@ -23,17 +23,17 @@ export const usePopConfirm = ({ defaultVisible: false, visible: visibleProp, onOpen, - onClose: () => { - onClose?.() - onCancelProp?.() - }, + onClose, }) + const onCancelLatest = useLatestCallback(onCancelProp) + const onCancel = useCallback(() => { + onCancelLatest() if (closeOnCancel) { visibleAction.off() } - }, [closeOnCancel, visibleAction]) + }, [closeOnCancel, visibleAction, onCancelLatest]) const onConfirmLatest = useLatestCallback(onConfirmProp) From 084600ea6e4fdec7efde79a3cc90d8ef45ca602f Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 23 Apr 2024 11:30:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore(pop-confirm):=20=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E8=AE=B0=E5=BD=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/brown-mails-accept.md | 5 +++++ .changeset/fast-waves-explode.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/brown-mails-accept.md create mode 100644 .changeset/fast-waves-explode.md diff --git a/.changeset/brown-mails-accept.md b/.changeset/brown-mails-accept.md new file mode 100644 index 000000000..d35b72803 --- /dev/null +++ b/.changeset/brown-mails-accept.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/pop-confirm": patch +--- + +fix: 修复点击按钮会触发 onCancel 问题 diff --git a/.changeset/fast-waves-explode.md b/.changeset/fast-waves-explode.md new file mode 100644 index 000000000..b918a14ca --- /dev/null +++ b/.changeset/fast-waves-explode.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +fix(pop-confirm): 修复点击确定按钮会触发 onCancel 问题