Skip to content

Make possible to use a SimpleList as a child of an ArrayField#6975

Merged
fzaninotto merged 2 commits intomasterfrom
fix-array-field-total
Dec 15, 2021
Merged

Make possible to use a SimpleList as a child of an ArrayField#6975
fzaninotto merged 2 commits intomasterfrom
fix-array-field-total

Conversation

@Luwangel
Copy link
Copy Markdown
Contributor

Description

The <ArrayField> builds a list context by passing null as total. The SimpleList expects a total > 0 to be rendered. Both are incompatible.

I studied two solutions:

  1. Compute the total using ids (chosen)
  2. Remove the total > 0 condition

To not introduce breaking changes, and because it's cleaner, I choose the first solution.

Related Issue

Fixing #6974

@Luwangel Luwangel added the RFR Ready For Review label Dec 10, 2021
@Luwangel Luwangel changed the title Pass the total of ids when building the list context of the ArrayField Make possible to use a SimpleList as a child of an ArrayField Dec 10, 2021
@Luwangel Luwangel requested review from djhi and fzaninotto December 10, 2021 16:31
@djhi djhi added this to the 3.19.4 milestone Dec 14, 2021
Copy link
Copy Markdown
Contributor

@djhi djhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for the ArrayField and SimpleList?

@vercel vercel Bot temporarily deployed to Preview – react-admin December 15, 2021 14:21 Inactive
@vercel vercel Bot temporarily deployed to Preview – react-admin-storybook December 15, 2021 14:21 Inactive
@fzaninotto
Copy link
Copy Markdown
Member

Why don't you use useList? It's the perfect use case for it.

https://github.com/marmelab/react-admin/blob/next/docs/useList.md

@Luwangel
Copy link
Copy Markdown
Contributor Author

Why don't you use useList? It's the perfect use case for it.

https://github.com/marmelab/react-admin/blob/next/docs/useList.md

The fix here is to make the ArrayField / SimpleList work together. But you're right, there are other ways to build this kind of feature.

@fzaninotto fzaninotto merged commit e51a6c6 into master Dec 15, 2021
@fzaninotto fzaninotto deleted the fix-array-field-total branch December 15, 2021 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants