-
-
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
initialValue on BooleanInput inside ArrayInput resets value of BooleanInput on Edit #6511
Comments
Sorry, did you have time to look at it ? |
Confirmed, thanks for the report. |
This looks like a bug in react-final-form-arrays. I'll investigate further, but I'm not sure there is something we can do about it. |
The problem doesn't lie in the ArrayInput logic: even when using BooleanInput outside of an ArrayInput, I manage to reproduce the bug. https://codesandbox.io/s/billowing-star-s9mzv?file=/src/data.tsx |
As my Codesandbox shows, the problem seems to be in react-final-form's handling of initialValue with a value false on a single input. As a workaround, setting the initialValues on the form doesn't seem to trigger the bug. |
The problem isn't in react-final-form's handling of initialValue with false value, as this simpler CodeSandbox shows: https://codesandbox.io/s/lively-darkness-jvst7?file=/src/App.js |
I traced the bug to react-admin/packages/ra-core/src/form/useInput.ts Lines 117 to 134 in b007fb7
For mysterious reasons, the Now why is the final-form input value undefined in the first place? |
OK, the problem comes from the fact that final-form doesn't set So we can't base our decision to reset the field to its default value just on the presence of a value ; we must also see if the input Fix incoming! |
What you were expecting:
When editing a record that contains a
BooleanInput
inside anArrayInput
, theBooleanInput
should have the last known value.What happened instead:
When editing, the
BooleanInput
displays theinitialValue
. Which means that after saving theBooleanInput
is reset to itsinitialValue
.Steps to reproduce:
In the CodeSandbox below :
true
BooleanInput
is not set totrue
but tofalse
true
so it should be true in the edit viewfalse
instead oftrue
.Related code:
https://codesandbox.io/s/brave-dhawan-l5sfk
Other information:
Environment
(ping @dorian-ubisoft)
The text was updated successfully, but these errors were encountered: