inveniosoftware / react-invenio-deposit

React application for Invenio deposit forms.
https://react-invenio-deposit.readthedocs.io
MIT License
3 stars 46 forks source link

PIDField: fix display of initial errors #511

Closed jrcastro2 closed 2 years ago

jrcastro2 commented 2 years ago

image

jrcastro2 commented 2 years ago

I think I will need a call to understand how this works :)

I can try to explain it here so everyone can check it but feel free to reach out if not clear enough.

We also need to check for the initialErrors mainly because we have added the formik option enableReinitialize that apparently resets the form when the props change (when submitting as example). Meaning that every time the props change the form resets and the Errors prop is cleared. In order to still keep the errors we store them in InitialErrrors (see "workaround" here). So when we display the errors, first we need to check for the Errors prop of Formik and if empty we also need to check for the InitialErrrors prop as the errors might be cleared due to enableReinitialize.