react-final-form icon indicating copy to clipboard operation
react-final-form copied to clipboard

beforeSubmit 'value' is undefined error after removing neighboring text input

Open chloelangston opened this issue 3 years ago • 3 comments

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.

Issue

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, 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

Screen Shot 2022-03-29 at 4 10 25 PM

chloelangston avatar Mar 29 '22 20:03 chloelangston

I saw the same issue using <FieldArray> also. I fixed/worked-around it by removing the format and formatOnBlur attributes for an Input <Field .../> inside the array.

jadefisher avatar Aug 12 '22 00:08 jadefisher

I had the same problem. Instruction above works.

Any update?

metju312 avatar Dec 07 '22 08:12 metju312