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

ArrayInput issues with nested properties #8256

Closed
marhali opened this issue Oct 12, 2022 · 2 comments
Closed

ArrayInput issues with nested properties #8256

marhali opened this issue Oct 12, 2022 · 2 comments
Labels

Comments

@marhali
Copy link

marhali commented Oct 12, 2022

What you were expecting:

I want to use the ArrayInput with a nested property structure like this:

{
    "numbers": [
        {
            "nested": {
                "number": "10"
            }
        }
    ]
}

What happened instead:

The data gets displayed properly but if I remove an item from the array and want to add a new item, the old data gets displayed.
This does not happen if I do not use a nested property for the source parameter.
Another problem is the save button which will not display the correct state (enabled, disabled) on nested properties.

Steps to reproduce:

Related code:

See this example with a nested property structure:
https://stackblitz.com/edit/github-rmhseu?file=src/data.tsx

<Edit>
    <SimpleForm>
      <ArrayInput source="numbers" defaultValue={[{ nested: { number: 1 } }]}>
        <SimpleFormIterator>
          <NumberInput source="nested.number" defaultValue={1} />
        </SimpleFormIterator>
      </ArrayInput>
    </SimpleForm>
  </Edit>

Other information:

Environment

  • React-admin version: 4.4.1
  • React version: 17
  • Browser: chrome
@slax57
Copy link
Contributor

slax57 commented Oct 12, 2022

Reproduced, thanks!

Might be the implementation of #8204 that only clears objects at depth=1

@slax57 slax57 added the bug label Oct 12, 2022
@djhi
Copy link
Collaborator

djhi commented Aug 18, 2023

Cannot reproduce anymore on 4.13.0

@djhi djhi closed this as completed Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants