Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in ArrayInput still not fully solved #7027

Closed
DjebbZ opened this issue Dec 23, 2021 · 5 comments
Closed

Bug in ArrayInput still not fully solved #7027

DjebbZ opened this issue Dec 23, 2021 · 5 comments

Comments

@DjebbZ
Copy link
Contributor

DjebbZ commented Dec 23, 2021

What you were expecting:
We still have the issue reported in the fake PR #6908, that was supposed to be fixed in RA 3.19.3. The temporary workaround of pinning to a specific version of final-form works, but removing this specific version of
final-form and moving to RA version 3.19.3 did not solve the problem of disappearing values inside <ArrayInput>s.

What happened instead:
To be able to upgrade to 3.19.4 (since it was released since then), we also had to change all initialValue props to defaultValue (at the field level). The combination of RA 3.19.4 + defaultValue props + removing the specific version of final-form is what worked for us to be able to upgrade RA.

Steps to reproduce:
Sadly, we didn't manage to create a reproduction case, the one in the PR mentioned above is the closest thing to our production code we could come up with. There must be something we missed, but we can't see what.

Related code:
We did a bit of digging inside RA code and from our understanding, the fix of RA 3.19.3 (#6932) deals with initialValue, but defaultValue is handled in another code path, which seems to be why using defaultValue works for us and not initialValue. I hope this hint can give you enough information to try to track the problem, which seems to be tricky.

Environment

  • React-admin version: 3.19.3, 3.19.4
  • Last version that did not exhibit the issue (if applicable): N/A
  • React version: 17
  • Browser: All
@WiXSL
Copy link
Contributor

WiXSL commented Jan 6, 2022

@DjebbZ,
I've tried to set up different scenarios to reproduce the problem but without success.
Could you please make another try at generating a simple, reproducible use case to work with?

@DjebbZ
Copy link
Contributor Author

DjebbZ commented Jan 6, 2022

I'll give it a try soon. I would love to get the final word on this problem.

@DjebbZ
Copy link
Contributor Author

DjebbZ commented Jan 7, 2022

We tried hard today, with no luck. The best we could come up with is this, which works perfectly but is even closer to our actual code than our precedent example.

https://codesandbox.io/s/beautiful-mestorf-26h9p?file=/src/posts/PostCreateEditForm.tsx.

In our code, striping down a similar form to keep only the reward ArrayInput (cf. CodeSandbox) works with defaultValue but doesn't with initialValue. Hopefully this information can help you find the problem.

@DjebbZ
Copy link
Contributor Author

DjebbZ commented Jan 17, 2022

Ok, final answer here. The problem came from our side :) We create custom views and forgot to pass the record to the forms under certain circumstances. It was also the occasion for us to "double-validate" the fix introduced in React-admin 3.19.3 that was supposed to correct the problem, and indeed it fixes it.

So far so good ! And no more problem with <ArrayInput>s.

@DjebbZ DjebbZ closed this as completed Jan 17, 2022
@WiXSL
Copy link
Contributor

WiXSL commented Jan 17, 2022

I'm glad you could solve the problem! 💪
Thanks for the feedback.
Please, open another issue at any time if you find any related problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants