final-form / final-form/react-final-form
beforeSubmit 'value' is undefined error after removing neighboring text input
- 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. Though this error is coming from React Final Form, my application uses React Final Form through React Admin.
### What is the current behavior?
I am unable to save a page after removing a text input from an array and seeing the error in the console, `Uncaught TypeError: Cannot read properties of undefined (reading 'value') at Object.beforeSubmit react-final-form.cjs.js:555`. This seems to happen inconsistently as at times I'm able to remove the element above it successfully. I created a test page with very minimal data to demo the issue in the video below.

### What is the expected behavior?
I would expect if I had been able to save the data upon creation, it should not give me an error when I remove a different item in the array.
### Sandbox Link
In [this CodeSandbox](https://codesandbox.io/s/twilight-meadow-qil5me?file=/src/posts/PostEdit.js), I was able to recreate a _similar_ error `sanitizeEmptyValues.js:18 Uncaught TypeError: Cannot read properties of undefined (reading 'url')`
Steps to recreate:
* Click into the first post and into the Miscellaneous tab
* Create a few backlinks some with dates and urls, some blank
* Remove one of the items that has a url, not one of the ones that's blank
* You should see this error in the console
* If not, try adding and removing a few more times, it seems inconsistent
### What's your environment?
🏁 Final Form version: 4.20.2
Browser: Chrome
### Error details in react-final-form.cjs.js

Contributor guide
Assessment
This issue has not been assessed yet.