Skip to content

Commit

Permalink
fix(pop-confirm): 修复点击确定按钮会触发onCancel(XiaoMi#2810)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiamiao committed Apr 22, 2024
1 parent 5fdea15 commit 486cd4f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/ui/pop-confirm/src/use-pop-confirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 486cd4f

Please sign in to comment.