-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[DataGrid] Fix display of row count and selected rows on mobile #508
[DataGrid] Fix display of row count and selected rows on mobile #508
Conversation
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.
It doesn't fit on mobile with pagination:
https://deploy-preview-508--material-ui-x.netlify.app/components/data-grid/pagination/
Yes about that, I saw it (its event worst if you select a row) but I'm not sure how to handle it design-wise. Maybe we can have a discussion about it. The fix will be easy to implement. What do you think @oliviertassinari ? |
What about we make it use two rows if the features are enabled? cc @dtassone |
That would definitely solve the issue but with the tradeoff that the footer height will increase and if you have set your grid to height to a smaller number there may bot be enough height for the visible part (although I'm not sure how valid of an argument that is since setting the height of the Grid is done by the user) |
Oh right, in this case, maybe we can have at most one footer "row":
|
How about we hide a few things in the pagination component. |
For the info about rows we can change it as well, reduce the wordings or put it on 2 rows 200 Rows, 1 selected |
The wordings will need to be translated with an API, it will increase it. It might also still overflow in another locale, so I would vote against for simplicity. Can a mobile user leverage the information? |
Yeah maybe just the total rows on mobile. Also can we put only 2 btns for pagination? |
I'll play around and create a couple of options and attach them here as screenshots to see which one will look the best |
Mayby hiding the rows per page would be enough. The best case is if we can manage the logic with CSS only, so its easier to customize (as opposed to changing the DOM). |
Ok I did some tests and it seems that the easies and most secure option is what @oliviertassinari suggested - hide the selected row and total row count. The reason is that the for the footer we are using the |
@DanailH Sounds good, so and on desktop, we leave it untouched. |
How about we keep what is circled in orange only? The row counter is actually displayed already in the pagination |
Sure, we can do that. Currently, it hides it also on desktop but I can easily change it 😉 |
This change will still require to update/change the |
You can do it with CSS |
You can also display the grid row counter only when there is no pagination |
Yes, that's what I'm doing now. If the pagination is available the |
True, but should we do it like this, hack our own components. It's better to introduce a prop in the |
@DanailH The data grid relies on core v4 so far, we can't expect any changes to land in it. However, the table pagination exposes enough public API, so no need to hack around. |
…m TablePagination
@@ -11,6 +12,16 @@ export interface PaginationComponentProps { | |||
rowsPerPageOptions?: number[]; | |||
} | |||
|
|||
// Used to hide the drop down select from the TablePaginagion | |||
const useStyles = makeStyles({ |
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.
Ok, I've updated the logic with what we discussed during the planning today, here is the summary:
- Remove
Total Rows
when the pagination is available - Remove the select and the label inside the
TablePagination
- Update the login so the
selected rows
is only shown on desktop when the pagination is available - Adjust the footer items alignment when there is only pagination (it should be aways on the right side)
Last but not least a question - these styles are needed to hide the select from the TablePagination
component but I'm not sure it this is the best place to keep them, ideas ?
Hmm I guess the flaky test is this one |
@DanailH CircleCI allows to rerun test from fails. I have launch it. |
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.
I wonder how to best test this. Maybe DOM and class name assertions would be ideal.
ref={ref} | ||
className={classnames({ | ||
'MuiDataGrid-footer-pagination-visible': isPaginationAvailable, | ||
'MuiDataGrid-footer-justifyContent-right': justifyItemsRight, |
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.
Adding a hypen for separating internal components was one thing, doing it for naming is another.
'MuiDataGrid-footer-justifyContent-right': justifyItemsRight, | |
'MuiDataGrid-footer-justifyContentRight': justifyItemsRight, |
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.
Instead of "right" using "end" would be better for RTL.
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.
What if we render an empty div instead so we don't have to apply a custom class name?
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.
Or we could also inverse the direction of the flex container. That could be even better if that's what most people would want, not sure.
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.
I was thinking of rendering an empty div as well but I didn't like how it looked. Maybe we can reintroduce it. The benefit is that if we add a single empty div around the row selected
we don't need to add any additional CSS logic/styles.
'& .MuiDataGrid-rowCount, & .MuiDataGrid-selectedRowCount': { | ||
visibility: 'hidden', | ||
[theme.breakpoints.up('md')]: { | ||
visibility: 'visible', |
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 using display none?
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.
I need it to take space. The reason is that we want the pagination to always be right-aligned. If I make it display: none
then the logic to aways align the pagination on the right will be unnecessarily complex.
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
…ailH/material-ui-x into fix/DataGrid-440-footer-issue-mobile
I wonder if we shouldn't use the breakpoint before |
I just went ahead and changed it to |
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.
- We can no longer change the number of rows per page on desktop, maybe use CSS to target the first
.caption
style on mobile? - Something is strange with this demo:
https://deploy-preview-508--material-ui-x.netlify.app/components/data-grid/pagination/#auto-size
I'll check the demo. Regarding the other point - as far as I understood that was the desired behaviour from our discussion, to hide both the label and the select? I can only hide the label and keep the select. |
I was under the assumption that it was only on mobile to save space. From my perspective, if we were to change this on desktop too, it would be the type of change that should be done at the |
Ok, hopefully, the last update - I've only hidden the Rows per page + the select from mobile resolutions, they are now visible on desktop. The drawback - I had to return the media query to |
) * Enable Row Count and Selected Rows on mobile * Hide RowCount and SelectedRowCount if paginationComponent is provided * Hide Row count and Selected rows on mobile if Pagination is available * Hide Total rows when there is pagination, remove select and label from TablePagination * Update packages/grid/_modules_/grid/components/pagination.tsx Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> * Adjust class names * Swap Total Row and rows selected places * Update footer breakpoint to "sm" * Fix formatting * Fix responsive styles Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Fixes #440
This PR aims to solve the issue of having the
Total Rows
androws selected
counts hidden on small screens. I didn't change the styling but only made the 2 files visible.