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] Add sort icon for when column is unsorted #1415
Conversation
Why do we need the 'unsorted' value exactly? So does |
packages/grid/_modules_/grid/components/containers/GridRootStyles.ts
Outdated
Show resolved
Hide resolved
To summarise:
|
If he changes the icon to null/false/undefined the default icon is used. If changed to an empty component (e.g.
Same problem as above.
The idea of controlling if the unsorted icon should be displayed came from this comment. However, instead of changing to an enum and creating a breaking change, I kept the boolean but added the third option. The Autocomplete API uses this approach in |
docs/src/pages/components/data-grid/columns/StylingHeaderGrid.js
Outdated
Show resolved
Hide resolved
|
To add a bit to what we have discussed:
|
packages/grid/_modules_/grid/components/columnHeaders/GridColumnHeaderItem.tsx
Outdated
Show resolved
Hide resolved
as a side note, this column menu demo is really bad. It just shows how to disable it |
Fixed.
Fixed.
I changed to importExport but I'm still not happy. I think we should only show the icon on hover and use the same icon of the next sort direction. #1076 (comment)
I related this problem here. It's a trade-off of fixing the alignment when using |
Yes but the tradeoff seems that it hurts more than the issue. Have you tried with a negative margin?
Well the issue is to provide the ability to show the unsorted icon when the column is not sorted. If we show the next direction then it would be a different spec. It could be a new option on sortable columns. Something like For the current issue, we have 2 default options.
As the grid should always come with as many feature as possible, I would lean towards 2. |
Same problem. I applied a negative
We added the icon slot for the unsorted icon, users can use any icon they want. My point is which icon should we use as the default one. Since we don't have a proper one my idea was to reproduce the same behavior of #1076 (comment) here. I just added now the |
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.
- How about we document this in https://deploy-preview-1415--material-ui-x.netlify.app/components/data-grid/sorting/?
- It seems that there are broken styles. I don't understand why we use a translateX. This is counterintuitive to me.
packages/grid/_modules_/grid/components/containers/GridRootStyles.ts
Outdated
Show resolved
Hide resolved
As discussed
|
<ColumnHeaderFilterIcon counter={filterItemsCounter} /> | ||
{column.sortable && !column.hideSortIcons && ( |
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.
} else if (direction === 'desc') { | ||
Icon = icons!.ColumnSortedDescendingIcon!; | ||
} | ||
return <Icon fontSize="small" className="MuiDataGrid-sortIcon" />; |
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.
Added fontSize
to match with ColumnHeaderFilterIcon
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.
Outside of the font size regression?, it looks great.
Opps, I have fired too quicky. There are visual regressions in the demos. For instance, here https://deploy-preview-1415--material-ui-x.netlify.app/components/data-grid/#mit-version, we need a larger width
There are also the issues with the icon on top of the other mentioned |
As mentioned in the link I put, if you reduce the size of the columns then the icons overlap each others |
@dtassone That's a side effect of removing With |
The only link I can find is https://deploy-preview-1415--material-ui-x.netlify.app/components/data-grid/columns/#column-menu. I personally can't see any issue. The columns are not resizable on these demos. I can see something wrong in https://deploy-preview-1415--material-ui-x.netlify.app/components/data-grid/columns/#column-reorder. |
try overriding the style below. .MuiBadge-anchorOriginTopRightRectangle {
top: 0;
right: 0;
transform: scale(1) translate(30%, -50%); <= the fix is here, change from 50 to 30%.
transform-origin: 100% 0%;
} |
@dtassone Same problem. If we invert the horizontal anchor of the |
you have to restore the overflow and your changes |
@m4theushw It does feel better too. We would only need to make sure it works if the text alignment is reversed. Otherwise, we could reduce the padding of |
@m4theushw you would need to accept the new screenshots to fix the build 😉 |
Hello guys. Finally, the feature to "add sort icon for when column is unsorted" (for component) is not implemented? Because I can't see in the docs (for previous version [4] or the new version [5]) any references to it. If it is not implemented and will not be implemented soon, do you have any suggestion of workaround? Thx! |
Closes #1076
Preview: https://deploy-preview-1415--material-ui-x.netlify.app/components/data-grid/demo
This PR changes the usage of the
hideSortIcons
prop. Usingfalse
will display an intermediary icon when no sort is applied. To keep the old behavior I've added anotherunsorted
(default now) value to only show the sort icon when there's a sort applied.