fix(component): useConfirmModal can't be closed automatically when 'onConfirm' is non-async (#6439)

This commit is contained in:
CatsJuice
2024-04-02 08:23:26 +00:00
parent 3c01d944fb
commit 381be8a982
2 changed files with 23 additions and 2 deletions

View File

@@ -104,8 +104,8 @@ export const ConfirmModalProvider = ({ children }: PropsWithChildren) => {
const onConfirm = () => {
setLoading(true);
_onConfirm?.()
?.then(() => onSuccess?.())
return Promise.resolve(_onConfirm?.())
.then(() => onSuccess?.())
.catch(console.error)
.finally(() => autoClose && closeConfirmModal());
};