final-form / final-form/react-final-form
dirtySinceLastSubmit does not work within onSubmit
- Dominant language
- JavaScript
- Stars
- 7.4k
- Forks
- 497
- PR merge metrics
- No merged PRs in 30d
Description
### Are you submitting a **bug report** or a **feature request**?
Bug report
### What is the current behavior?
`dirtySinceLastSubmit` is always false and `dirtyFieldsSinceLastSubmit` is always an empty Object when accessed via `form.getState()` within the `onSubmit` function.
### What is the expected behavior?
`dirtySinceLastSubmit` should be true if the form values are different from the values it was last submitted with. false otherwise. Comparison is done with shallow-equals.
`dirtyFieldsSinceLastSubmit` should be an object full of booleans, with a value of `true` for each field that has a different value from the one when the form was last submitted.
### Sandbox Link
https://codesandbox.io/s/hidden-microservice-lmq65?file=/index.js
This is forked from [the submission errors example](https://final-form.org/docs/react-final-form/examples/submission-errors), with the only change being the addition of the `console.log`s and the second `form` argument to `onSubmit`.
To reproduce, submit the form once with any values. Then change either or both values and submit again. In the console, there will be false and an empty object logged regardless of which values were changed.
### What's your environment?
React Final Form version 6.3.4
Final Form version 4.20.1
### Other information
Similar to #692, but accessing `dirtyFieldsSinceLastSubmit` in a different way.
`modifiedSinceLastSubmit` may have the same issue as well.
Contributor guide
Assessment
This issue has not been assessed yet.