From ebbb13f16303adcb440519dba28ad06c36b93d6a Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 23 Apr 2024 11:27:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(pop-confirm):=20=E4=BF=AE=E5=A4=8D=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E7=A1=AE=E5=AE=9A=E6=8C=89=E9=92=AE=E8=A7=A6=E5=8F=91?= =?UTF-8?q?onCancel=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)