Skip to content

Bug: DateInput & ArrayInput - formatOnBlur triggers undefined ref in react-final-form #6459

Closed
@SchaeVHS

Description

@SchaeVHS

Dear Team,
many thanks for react-admin and your work!

Version
"react": "^16.7.0",
"react-admin": "^3.17.0",
"react-scripts": "4.0.3",

Code Basis of bug

<ArrayInput source="positions" >
                    <SimpleIterator > 
                        <DateInput source="delivery_date"/>
                        <DateInput source="payment_date"/>
                    </SimpleIterator>
  </ArrayInput>

Problem
If you have multiple array elements and delete an array element in the middle by clicking on the delete button,
the EDIT form is not submitted/saved when clicking on the EDIT save button.

Observation
The browser console reports
grafik

Looking at the code it is that following react-final-form code which is triggered:
https://github.com/final-form/react-final-form/blob/2d9e7129f40efd39450c1d581956e8cfce17a20a/src/useField.js#L68

This only happens in react-admin for datefields, as datefields set "formatOnBlur":

Summary
I think it is a mixed problem:

  1. React final form doesn't check the return value of getFielState()
  2. react-admin SimpleFormIterator somehow deletes the fields in a way, that react-final-form still wants to iterate over it,
    although they are deleted?

I would really appreciate a fix, I have no idea how to proceed. With your help I can also offer to fix it myself,
but I'm lost. Is it react-final-form or is it react-admin which causes this?

Regards,
Daniel

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions