From eba921d2eefb2ed698803390c14ba989578bcad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Klaman?= Date: Sun, 16 May 2021 21:17:55 +0200 Subject: [PATCH] fix: isSubmitting not being set to true while Promise received from submit onSuccess callback is processing --- src/core/hooks/use-form-controller/formts-methods.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/hooks/use-form-controller/formts-methods.ts b/src/core/hooks/use-form-controller/formts-methods.ts index 1c45b41..c6d323b 100644 --- a/src/core/hooks/use-form-controller/formts-methods.ts +++ b/src/core/hooks/use-form-controller/formts-methods.ts @@ -175,8 +175,9 @@ export const createFormtsMethods = ({ dispatch({ type: "submitFailure" }); return onFailure(errors); } else { - dispatch({ type: "submitSuccess" }); - return onSuccess(state.values.val); + return onSuccess(state.values.val).map(() => { + dispatch({ type: "submitSuccess" }); + }); } }) .mapErr(err => {