final-form / react-final-form

🏁 High performance subscription-based form state management for React
https://final-form.org/react
MIT License
7.39k stars 481 forks source link

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

Open chloelangston opened 2 years ago

chloelangston commented 2 years ago

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:

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
jadefisher commented 2 years ago

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.

metju312 commented 1 year ago

I had the same problem. Instruction above works.

Any update?

dimireme commented 2 months ago

Faced the same issue and solve it by adding key property while use field.map.