-
-
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
Bug in nested ArrayInput with initialValue(s) #6908
Conversation
Could you describe the bug you are trying to fix? |
Done, I updated the description (I created the PR from CodeSandbox without a description nor a proper title) |
(Sorry if I created a PR instead of an issue, but the diff directly in GitHub looked like a good idea to me) |
It may be related to this issue #6900, not sure though. |
I tracked it down to |
Hi @DjebbZ, |
<ArrayField source="pictures"> | ||
<Datagrid> | ||
<ImageField source="url" /> | ||
<ArrayField source="metas.authors"> | ||
<Datagrid> | ||
<TextField source="name" /> | ||
</Datagrid> | ||
</ArrayField> | ||
</Datagrid> | ||
</ArrayField> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I added to the simple
example (+ updating react-admin in package.json)
Replied via a comment in the diff, because it's too tedious to revert just the code styles. No idea why your prettier config wasn't caught by my IDE. |
<ArrayInput source="pictures"> | ||
<SimpleFormIterator> | ||
<TextInput source="url" initialValue="" /> | ||
<ArrayInput source="metas.authors"> | ||
<SimpleFormIterator> | ||
<TextInput source="name" initialValue="" /> | ||
</SimpleFormIterator> | ||
</ArrayInput> | ||
</SimpleFormIterator> | ||
</ArrayInput> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I also added this part (this is in fact the most important part of the bug report)
Got it, reproduced |
return ( | ||
<Edit title={<PostTitle />} actions={<EditActions />} {...props}> | ||
<TabbedForm | ||
initialValues={_.merge({}, { average_note: 0, pictures: [] })} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to say that I also I added this part : a global object for the initialValues. Since the ArrayInput field prevents us from specifying here the shape of the pictures
field, I had to also add initialValue
at the field level. This global initialValues
may be important for the bug.
So, I tried to reproduce it locally both on |
Have you looked at my last comment ? ( |
I did and tried in both branches |
Me neither, I'm trying to figure out what's missing and will update the PR. |
I managed to reproduce, that's quite a sneaky one. In CodeSandbox, according to the docs, it will run the But when trying to reproduce locally, I use (and I'm you did too) the And in our application, we use If you run the simple example locally with |
I also updated the PR code with my local reproduction case, now the diff is very clean and easy to read. |
Regarding |
Thanks for the details! I'll dig |
Any news ? Any way I can help investigate the issue ? Any pointer welcome to help you debug this, I don't really know where to start. |
I can now reproduce it locally on |
Found it! It looks like a regression in final-form. I still have to find the exact source of this issue though. |
I can confirm that the workaround works, thanks A LOT! Are you capable of telling since which version of RA this regression caused the bug? I want to estimate the potential damage in our app. |
Actually, it shouldn't have worked before. Final-form array fields are dynamic by nature and the documentation clearly state that the
Nope |
Thanks for detailed answer. |
Yes ! So this should be in the next release, hopefully on Friday right ?
…On Tue, Dec 7, 2021, 16:55 Francois Zaninotto ***@***.***> wrote:
Closed #6908 <#6908> via #6932
<#6932>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6908 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAS3XSTESENG33Y3O5RG5TUPYVAJANCNFSM5I22KNEA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Oh didn't see 3.19.4 !
…On Tue, Dec 7, 2021, 20:35 Khalid Jebbari ***@***.***> wrote:
Yes ! So this should be in the next release, hopefully on Friday right ?
On Tue, Dec 7, 2021, 16:55 Francois Zaninotto ***@***.***>
wrote:
> Closed #6908 <#6908> via
> #6932 <#6932>.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#6908 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAAS3XSTESENG33Y3O5RG5TUPYVAJANCNFSM5I22KNEA>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
>
|
What you were expecting:
When I open the Edit view of a resource that has nested ArrayInput and use some
initialValue(s)
both at the form level and the field, the inputs for this part of the data shows the value from the dataProvider.What happened instead:
Instead, the inputs display the initialValue at the field level, making it easy for editor that modify another part of the record to override the existing data!
Steps to reproduce:
initialValue
set to""
butdata.tsx
(should bedata.ts
BTW) has actual data.Related code:
The sandbox https://codesandbox.io/s/reproduce-nested-arrayinput-default-value-bfpnr has all the code, and I created this pull request to highlight the small set of changes I made to reproduce the bug.
Other information:
It may be related to a similar issue we created related to
<BooleanIinput />
in nested ArrayInput, not sure (#6511)Environment