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] horizontal scroll behavior is different between light mode and dark mode #1613

Closed
2 tasks done
trfv opened this issue May 9, 2021 · 12 comments · Fixed by #1703
Closed
2 tasks done

[DataGrid] horizontal scroll behavior is different between light mode and dark mode #1613

trfv opened this issue May 9, 2021 · 12 comments · Fixed by #1703
Assignees
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!

Comments

@trfv
Copy link

trfv commented May 9, 2021

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

DataGrid horizontal scroll behavior is different between light mode and dark mode.

datagrid_horizontal_scroll.mov

Expected Behavior 🤔

Dark mode behavior should be the same as light mode one.

Steps to Reproduce 🕹

You can try it here.
https://material-ui.com/components/data-grid/components/

Context 🔦

I tried to implement dark mode, and found this bug.
The difference may come from here.
https://github.com/mui-org/material-ui-x/blob/master/packages/grid/_modules_/grid/components/containers/GridRootStyles.ts#L331-L363

Your Environment 🌎

macOS Big Sur version 11.2.3
Google Chrome 90.0.4430.93(Official Build) (x86_64)

@trfv trfv added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 9, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented May 9, 2021

Interesting, yeah, we knew about this when we picked the current implementation: #660 (comment)

@dtassone dtassone added bug 🐛 Something doesn't work docs Improvements or additions to the documentation and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 10, 2021
@trfv
Copy link
Author

trfv commented May 10, 2021

@oliviertassinari

Thank you for your quick response. I could not find this discussion... 🙇

Then, are there any workaround?
I tried this way in my repo and all scroll bar are hidden.

const theme = createMuiTheme({
...
overrides: {
   MuiCssBaseline: {
     "@global": {
       "*::-webkit-scrollbar": {
         display: "none",
     },
   },
 },
...
});

@oliviertassinari oliviertassinari added component: data grid This is the name of the generic UI component, not the React module! and removed docs Improvements or additions to the documentation labels May 10, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented May 10, 2021

I have removed the "docs" label as it's not specific to our docs (it's only one way to reproduce it). We can create the same reproduction in codesandbox simply by enabling the dark mode: https://codesandbox.io/s/material-demo-forked-pt05q?file=/demo.tsx.

@oliviertassinari oliviertassinari changed the title DataGrid horizontal scroll behavior is different between light mode and dark mode [DataGrid] horizontal scroll behavior is different between light mode and dark mode May 10, 2021
@dtassone
Copy link
Member

I have removed the "docs" label as it's not specific to our docs (it's only one way to reproduce it). We can create the same reproduction in codesandbox simply by enabling the dark mode: https://codesandbox.io/s/material-demo-forked-pt05q?file=/demo.tsx.

I don't see a horizontal scrollbar on this codesandbox 🤔

@oliviertassinari
Copy link
Member

oliviertassinari commented May 10, 2021

For me, it requires the default params:

Screenshot 2021-05-10 at 17 26 52

Then, I get:

Screenshot 2021-05-10 at 17 26 20

@dtassone
Copy link
Member

Yes I have the auto setting.

image

🤔

@trfv
Copy link
Author

trfv commented May 11, 2021

My setting is "When scrolling".

screenshot 2021-05-11 10 08 29

@oliviertassinari
Copy link
Member

oliviertassinari commented May 11, 2021

In any case, this bug is expected. We measure the scrollbar width on a hidden element, which returns 0px. Then, with CSS we force a scrollbar width on the data grid container. The horizontal scroll is of the width of the scrollbar we force.

@socramm
Copy link

socramm commented May 17, 2021

Are there any plans to change this behavior in the future? My customer is not pleased that a horizontal scrollbar is visible when not clearly needed.

I am currently looking for a workaround. Is it maybe possible to always use the default scrollbar regardless of dark or light mode?

A other solution that I am thinking of in the moment is to check programmatically if a header is overflowing and hide the scrollbar based on that.

@Primajin
Copy link

Primajin commented May 21, 2021

Also we have the issue that the scrollbars in dark mode don't automatically read the global theme colors but rather have some colors and borders hardcoded.

Our normal scrollbars in dark mode on Windows vs the ones in datagrid:

Relates to: mui/material-ui#25016

@oliviertassinari
Copy link
Member

Interesting. In mui/material-ui#25016 , I was proposing to expose darkScrollbar so developers could override other scroll containers, like the one of this component.

In your case, we might need to have a dedicated theme variable. But maybe we can be smart about it and start from the background color.

@oliviertassinari
Copy link
Member

I have opened #1805 to use the opportunity found by Matheus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
5 participants