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

[DataGrid] Fix separator styles on touch devices #14471

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions packages/x-data-grid/src/components/containers/GridRootStyles.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be in favor of removing these lines: https://github.com/mui/mui-x/pull/14471/files#diff-e1db53193a627d36d1cd3f651a954ee1e32ecb93caa020446631d722bb1be75cR447-R449
So that the separator is in an "active" state when you drag it on the touch screen.
What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout, updated here: 1b18a02

Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,13 @@ export const GridRootStyles = styled('div', {
`]: {
[`& .${c.columnSeparator}`]: {
opacity: 0,
'@media (hover: none)': {
},
// Show resizable separators at all times on touch devices
'@media (hover: none)': {
[`& .${c['columnSeparator--resizable']}`]: {
opacity: 1,
color: (t.vars || t).palette.primary.main,
Copy link
Member Author

@KenanYusuf KenanYusuf Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was problematic - the conditions of the separator being the primary color are different on touch devices to desktop. Moved here: https://github.com/mui/mui-x/pull/14471/files#diff-e1db53193a627d36d1cd3f651a954ee1e32ecb93caa020446631d722bb1be75cR415-R422

},
},
// Show resizable separators again when the column is hovered
[`& .${c['columnSeparator--resizable']}:hover`]: {
opacity: 1,
},
Expand Down Expand Up @@ -411,6 +412,14 @@ export const GridRootStyles = styled('div', {
},
'@media (hover: none)': {
[`& .${c.columnHeader}`]: columnHeaderStyles,
[`& .${c.columnHeader}:focus,
& .${c.columnHeader}:focus-within,
& .${c.columnHeader}:has(+ .${c.columnHeader}:focus),
& .${c.columnHeader}:has(+ .${c.columnHeader}:focus-within)`]: {
[`.${c['columnSeparator--resizable']}`]: {
color: (t.vars || t).palette.primary.main,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the motivation behind having separators in an "active" state when the column header cell is selected?

Copy link
Member Author

@KenanYusuf KenanYusuf Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the colors clash a little when the column group has a blue outline and the separators are grey. This situation never occurs on desktop because the separators are not visible when the column header is focused until the side is hovered (which also turns the separator blue).

Without:
Screenshot 2024-09-04 at 12 28 31

With:
Screenshot 2024-09-04 at 12 28 38

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this makes sense then 👍🏻

},
},
},
[`& .${c['columnSeparator--sideLeft']}`]: {
left: columnSeparatorOffset,
Expand All @@ -427,16 +436,17 @@ export const GridRootStyles = styled('div', {
[`& .${c['columnSeparator--resizable']}`]: {
cursor: 'col-resize',
touchAction: 'none',
[`&.${c['columnSeparator--resizing']}`]: {
color: (t.vars || t).palette.primary.main,
},
// Always appear as draggable on touch devices
'@media (hover: none)': {
[`& .${c.iconSeparator} rect`]: separatorIconDragStyles,
color: borderColor,
},
[`&:hover, &.${c['columnSeparator--resizing']}`]: {
color: (t.vars || t).palette.primary.main,
[`& .${c.iconSeparator} rect`]: separatorIconDragStyles,
'@media (hover: none)': {
color: borderColor,
'@media (hover: hover)': {
'&:hover': {
color: (t.vars || t).palette.primary.main,
[`& .${c.iconSeparator} rect`]: separatorIconDragStyles,
},
},
'& svg': {
Expand Down
Loading