formik icon indicating copy to clipboard operation
formik copied to clipboard

Trigger validation on Pop of array-of-objects

Open fenech opened this issue 3 years ago • 1 comments

Make a copy of the original array, so that validation happens the same as when calling Remove on the last element.

Test case: https://codesandbox.io/s/formik-fieldarray-change-validation-bug-forked-fddidy?file=/index.js note that after adding an element, clicking on "pop" doesn't clear the error, whereas clicking on its "x" button does.

This issue affects arrays of objects in the schema. Returning a copy of the old array, instead of the original, means that validation is triggered and the errors object is correctly updated.

fenech avatar Apr 27 '22 15:04 fenech

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

formik-docs – ./

🔍 Inspect: https://vercel.com/jared/formik-docs/A6K2Viw2kDZKeQCF4MV7maCgoR9P
✅ Preview: Failed

vercel[bot] avatar Apr 27 '22 15:04 vercel[bot]

Fixed in recent releases

quantizor avatar May 26 '23 20:05 quantizor