Skip to content

Commit

Permalink
Fixed initialValues not being cleared when options `clearAfterSubmi…
Browse files Browse the repository at this point in the history
…t` and `setInitialValuesOnSuccess` are both `true`
  • Loading branch information
jalik committed May 8, 2024
1 parent a912558 commit 5f0e711
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/useFormReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,9 @@ function useFormReducer<V extends Values, E, R> (
...(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,
Expand Down

0 comments on commit 5f0e711

Please sign in to comment.