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

[RFR] Display a skeleton instead of empty datagrid when loading #2706

Merged
merged 4 commits into from
Jan 1, 2019

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Dec 31, 2018

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.

kapture 2018-12-31 at 16 02 54

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.

kapture 2018-12-31 at 16 14 26

Tested on Datagrid directly descending a List, and descending a ReferenceManyField.

kapture 2018-12-31 at 16 17 35

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.

image

When React Suspense is a thing, we'll add a time threshold to display the skeleton only after a short delay.

@@ -135,7 +135,7 @@ export class ReferenceManyFieldController extends Component {
currentSort: this.state.sort,
data,
ids,
isLoading: typeof ids === 'undefined',
loadedOnce: typeof ids !== 'undefined',
Copy link
Member Author

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.

@fzaninotto fzaninotto added this to the 2.6.0 milestone Dec 31, 2018
resource,
basePath,
children,
linkType,
...rest
} = this.props;

if (loadedOnce === false) {
return <LinearProgress />;
Copy link
Collaborator

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 ?

Copy link
Member Author

@fzaninotto fzaninotto Jan 1, 2019

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).

Copy link
Collaborator

@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.

Nice! We just have to tackle the empty state now :)

@djhi djhi merged commit 6d95ef1 into next Jan 1, 2019
@djhi djhi deleted the List-skeleton branch January 1, 2019 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants