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

Consider the possibility to set emptyText to ArrayField or to it's children component #6661

Closed
soullivaneuh opened this issue Oct 12, 2021 · 2 comments

Comments

@soullivaneuh
Copy link
Contributor

soullivaneuh commented Oct 12, 2021

Is your feature request related to a problem? Please describe.

This request is a follow up of #6179.

Using the empty field of the Datagrid component is a solution. however, this field require only a react component.

This may be useful for some cases, but it is completely overkill if you just want to show a "It is empty" text just like other simple fields.

We may also use empty={<span>It is empty</span>}, however, we loose all the react-admin design of the Fields (Typography with specific config).

Describe the solution you'd like

Having a way to just put a emptyText props on a ArrayField, making the configuration much simpler:

<ArrayField
  source="userDiscountCodes"
  label="Codes promos associés"
  emptyText="Aucun"
>
  <Datagrid empty={<TextField emptyText="Aucun." />}>
  </Datagrid>
</ArrayField>

Or, if the ArrayField usage is a problem, maybe on the Datagrid component itself (and any of the usable children):

<ArrayField
  source="userDiscountCodes"
  label="Codes promos associés"
>
  <Datagrid emptyText="Aucun.">
  </Datagrid>
</ArrayField>

Describe alternatives you've considered

The only solution I found to get the exact same render with a minimal "code copy/paste" impact is this:

<ArrayField
  source="userDiscountCodes"
  label="Codes promos associés"
>
  <Datagrid empty={<TextField emptyText="Aucun." />}>
  </Datagrid>
</ArrayField>

Additional context

A side note about the last change: the emptyText was reported as not used for the ArrayField. However, this option is still present on the TS definition. Is it a wanted behavior?

@soullivaneuh
Copy link
Contributor Author

I have an another case with no solution, using the ChipFieldList:

<ReferenceArrayField
  source={source}
  label={label}
  reference="users"
  {...props}
>
  <SingleFieldList linkType="show">
    <UserIdentityChipField />
  </SingleFieldList>
</ReferenceArrayField>

The emptyText also has no effect (expected) but I don't have any empty field for this child.

How should I resolve this case? 🤔

@fzaninotto
Copy link
Member

This feature request hasn't received any attention from the community. As it's not on the roadmap of the core team, we're closing the GitHub issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants