From 5f0e71195720a62ef59ddc3f1cb355414ec34b64 Mon Sep 17 00:00:00 2001 From: Karl Stein Date: Wed, 8 May 2024 11:01:11 -1000 Subject: [PATCH] Fixed `initialValues` not being cleared when options `clearAfterSubmit` and `setInitialValuesOnSuccess` are both `true` --- CHANGELOG.md | 4 ++++ src/useFormReducer.ts | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1abe607..faf465b 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 5.4.1 (2024-05-08) + +- Fixed `initialValues` not being cleared when options `clearAfterSubmit` and `setInitialValuesOnSuccess` are both `true` + ## 5.4.0 (2024-05-06) - Fixed submit success not being updated when promise returned no result diff --git a/src/useFormReducer.ts b/src/useFormReducer.ts index fd4b5fb..b8f70e1 100644 --- a/src/useFormReducer.ts +++ b/src/useFormReducer.ts @@ -528,9 +528,9 @@ function useFormReducer ( ...(action.data.clear ? initialState : state), debug: state.debug, initialized: true, - initialValues: action.data.setInitialValuesOnSuccess - ? state.values - : state.initialValues, + initialValues: action.data.clear + ? initialState.initialValues + : (action.data.setInitialValuesOnSuccess ? state.values : state.initialValues), modified: false, modifiedFields: {}, submitCount: 0,