-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Hiding field deletes form values #3882
Comments
Reproduced and confirmed, thanks for the CodeSandbox. I suspect this is a react-final-form bug, would you mind opening an issue in their bug tracker? |
It doesn't seem to be reproducible with final-form only: https://codesandbox.io/s/kind-jang-0gyjg |
Thanks. Your last example is simpler than what we do in react-admin (you should use the same subscriptions and use a FormSpy), but I appreciate the effort. I'll dig further to try and understand what react-admin does wrong here. |
@fzaninotto I actually was trying out with the simple example and realized it's the Edit: It looks like in the migration from redux-form to final-form (306aef5), redux-form's |
Exactly, so I think #3884 should fix the problem. I'm going to test that patch more thoroughly. |
Fixed by #3884 |
👍 Thanks |
What you were expecting:
When upgrading to version 3 beta, I expected the forms to keep values even when fields are mounted / unmounted.
What happened instead:
If a form field is unmounted, the value of the field is removed from the form state. This is especially a problem in dynamic field and when displaying part of a form inside a modal.
Steps to reproduce:
Set up a field displayed based on another value as the doc mention (https://github.com/marmelab/react-admin/blob/next/docs/Inputs.md#linking-two-inputs), then when the condition changes and the field gets unmounted / remounted, it doesn't have a value anymore.
Related code:
https://codesandbox.io/s/vibrant-tereshkova-q6i27
Pick a user, enable the email toggle, the original email is present.
After disabling / enabling the toggle again, the email address is gone from the field:
Other information:
It looks like this is due to some internals of react-final-form, I didn't have time to investigate though.
It would be nice to figure a workaround, I'll update the issue if I can figure something out.
Environment
The text was updated successfully, but these errors were encountered: