-
-
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
[RFR] Display a skeleton instead of empty datagrid when loading #2706
Conversation
@@ -135,7 +135,7 @@ export class ReferenceManyFieldController extends Component { | |||
currentSort: this.state.sort, | |||
data, | |||
ids, | |||
isLoading: typeof ids === 'undefined', | |||
loadedOnce: typeof ids !== 'undefined', |
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 can be considered a BC break, but it was never documented, so I'm confident it should not break much.
resource, | ||
basePath, | ||
children, | ||
linkType, | ||
...rest | ||
} = this.props; | ||
|
||
if (loadedOnce === false) { | ||
return <LinearProgress />; |
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.
Why not faking multiple lines here too ?
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.
SingleFieldList can contain anything (usually in-line <ChipField>
) so I don’t think faking several lines does make sense here.
Besides, I just added the <LinearProgress>
here because I removed it from <ReferenceManyField>
: it’s now the responsibility of the child to display a loader, not the parent. That way, the loader can look like the upcoming content (e.g. data grid skeleton).
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.
Nice! We just have to tackle the empty state now :)
This PR slightly improves the User Experience by showing a skeleton datagrid during the first load instead of nothing. On slow networks, the previous user experience could lead the users to thing there is a bug.
Note that this only affects the first load. On subsequent renderings of the datagrid, react-admin still displays stale data while fetching up-to-date data (optimistic rendering).
The skeleton tries to minimize screen fickering by displaying checkboxes only when bulk actions are on, by showing as many columns as the datagrid has children, etc.
Incidentally, this also solves a UI problem that I used to think of "the lone record". When a users opens the app directly in a record detail page and goes back to the list, the list used to display only that record while loading the first page. Now it displays the skeleton instead.
Tested on
Datagrid
directly descending aList
, and descending aReferenceManyField
.Note that if the dataProvider fails fetching the list the first time, the skeleton will remain on screen. That's assumed.
Adds a new entry in the resource state to avoid changing the initial value of the list data or ids.
When React Suspense is a thing, we'll add a time threshold to display the skeleton only after a short delay.