You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There appears to be no way to display an empty state message when there are no results from a <ReferenceManyField />, despite docs suggesting the emptyText (common) field is supported.
What you were expecting:
When no results are returned for a referenced field, I expected my <ReferenceManyField /> to display the text defined in its emptyText attribute.
What happened instead:
Nothing is displayed except the <ReferenceManyField />'s label attribute.
Steps to reproduce:
Using the code sandbox below, view the show screen of any Post without comments.
I discovered the same is also true of ArrayField, and subsequently found discussion on #6179 covering the rationale.
TL;DR emptyText isn't supposed to work; it's a documentation issue.
The workaround is to use the child (eg. Datagrid's) empty attribute;
<ReferenceManyField...><Datagridempty={<p>There are no comments for this post</p>}>
...
or, to style your text the same as a normal emptyText...
importTypographyfrom'@material-ui/core/Typography'<ReferenceManyField...><Datagridempty={<Typographycomponent='span'variant='body2'>There are no comments for this post</Typography>}>
...
Feel free to close this issue, although hopefully it will help someone coming across this limitation in future.
There appears to be no way to display an empty state message when there are no results from a
<ReferenceManyField />
, despite docs suggesting theemptyText
(common) field is supported.What you were expecting:
When no results are returned for a referenced field, I expected my
<ReferenceManyField />
to display the text defined in itsemptyText
attribute.What happened instead:
Nothing is displayed except the
<ReferenceManyField />
'slabel
attribute.Steps to reproduce:
Using the code sandbox below, view the
show
screen of any Post without comments.Related code:
CodeSandbox (forked from simple example) -> https://codesandbox.io/s/boring-swirles-zpxq5
Entirely unchanged except to add:
in
/posts/PostShow.tsx
line ~101
.Other information:
The ReferenceManyField docs say that " also accepts the common field props." and
emptyText
is a common field prop.Environment
3.17.2
17.0.2
N/A
The text was updated successfully, but these errors were encountered: