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

Does Tab component attempt to hide vertical scrollbar? Does it work for you? #14706

Closed
mpodlasin opened this issue Mar 1, 2019 · 12 comments · Fixed by #15762
Closed

Does Tab component attempt to hide vertical scrollbar? Does it work for you? #14706

mpodlasin opened this issue Mar 1, 2019 · 12 comments · Fixed by #15762
Labels
bug 🐛 Something doesn't work component: tabs This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@mpodlasin
Copy link

mpodlasin commented Mar 1, 2019

I am using Chrome on MacOS.

On MaterialUI demo website, when I scroll tabs left and right, I DON'T see the vertical scroll.

https://material-ui.com/demos/tabs/#scrollable-tabs

And yet in all other examples (codesandbox, using component in own application) I can see the scrollbar. What baffles me is this inconsistent behaviour. What magic causes it? What makes matters worse is that some of my coworkers can see the scrollbar on their computers and others don't.

https://codesandbox.io/s/jjrkjopn8v

zrzut ekranu 2019-02-28 o 13 26 16

What's more, after digging into Tabs source code, I have seen that there is an attempt to measure scroll size. Does it work for you?

https://github.com/mui-org/material-ui/blob/next/packages/material-ui/src/Tabs/ScrollbarSize.js

My questions:

  • So what is overall status of scrollbar on Tabs component? Is presence of visible scrollbar considered a bug, or do we accept it?

  • Does anyone also get inconsistent behaviour where you don't see scrollbar in official demo but see it in codesandbox? Does anyone have any ideas what may cause it?

@oliviertassinari
Copy link
Member

The Tabs' scrollbar shouldn't be visible. How can we reproduce the problem?

@mpodlasin
Copy link
Author

mpodlasin commented Mar 1, 2019

Well, the provided codesandbox is a reproduction for me. I see scrollbar there.
I use chrome 65 on MacOS. Does it work ok for you?

My coworker on chrome 72 on MacOS has seen scrollbars even on material-ui demo website.

Also to be clear: I see scrollbar only while I am scrolling. Not on first render of webpage.

zrzut ekranu 2019-03-01 o 10 46 30 3

Potential fix:

What seems to work as a crude quick fix was setting this properties in css:
https://stackoverflow.com/a/35203104

This makes scrollbar have constant width, which makes ScrollbarSize component actually work and set proper size.

Or even simpler set for scrollable element:

.scrollable::-webkit-scrollbar {
  -webkit-appearance: none;
  width: 0;
  height: 0;
}

@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 2, 2019

@mpodlasin Interesting. I might know what's going on. MacOS has a smart scrollbar display logic. It's enabled by default but you can change it in the main settings:

capture d ecran 2019-03-02 a 19 34 26
sorry, french user here

I'm using the nondefault option that reproduces the Windows behavior: the scrollbar is always visible and has its own width. I have changed it as its the most common behavior. It helps me find scroll issue sooner.

We are measuring the scrollbar width in order to hide it: https://github.com/mui-org/material-ui/blob/c0287df54346221af06a5fea860a9d2e58e0f2d1/packages/material-ui/src/Tabs/Tabs.js#L127

It doesn't work in your case. I think that we can move your CSS code in the core. What do you think about it?

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. component: tabs This is the name of the generic UI component, not the React module! labels Mar 2, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 2, 2019

Given the browser support https://caniuse.com/#feat=css-scrollbar, we might be able to kill ScrollbarSize at some point.

@Romanior
Copy link

Screen Recording 2019-04-24 at 11 06 AM

I have visible scrollbars as well, in the situation when Tabs rendered in hidden container and then by controlling visibility of parent element <div hidden="false" />Tabs are shown. Resizing window makes them disappear, so I assume some event is not triggered on hidden element.

    "@material-ui/core": "4.0.0-alpha.8",

@oliviertassinari
Copy link
Member

@Romanior I believe it's a different issue. In your case, the scrollbar has it's own height. I like your customization, it would make a great new example in the documentation. I think that it's the same problem as #14077.

@Romanior
Copy link

@oliviertassinari Thank you for fast response, indeed this looks related to #14077. I ended up controlling visibility with

 &.--hidden {
      height: 0;
      overflow: hidden;
    }

@Romanior
Copy link

@oliviertassinari Would be happy to add it, can you please point to the best place to start with? Thanks.

@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 24, 2019

@Romanior It depends on what you mean. If you are referring to this issue resolution, what I have in mind is:

--- a/packages/material-ui/src/Tabs/Tabs.js
+++ b/packages/material-ui/src/Tabs/Tabs.js
@@ -36,6 +36,10 @@ export const styles = theme => ({
     display: 'inline-block',
     flex: '1 1 auto',
     whiteSpace: 'nowrap',
+    '&::-webkit-scrollbar': {
+      appearance: 'none',
+      height: 0,
+    },
   },
   /* Styles applied to the tablist element if `!variant="scrollabl. */
   fixed: {

If you are referring to the customzation demo, I was thinking of this demo: https://next.material-ui.com/demos/tabs/#customized-tabs. There is a couple of more customizations here https://mui-treasury.com/components/tabs, but none match the Bootstrap version like yours :).

@Umerbhat
Copy link
Contributor

Umerbhat commented May 20, 2019

@oliviertassinari I could replicate the issue of a visible scrollbar at https://material-ui.com/demos/tabs/#automatic-scroll-buttons

Screen Shot 2019-05-20 at 8 52 19 PM

I tried cross-browser vendor prefixed styling

scrollable: {
    overflowX: 'scroll',
    /* Hidden scrollbar vendor prefixed. */
    msOverflowStyle: 'none',
    overflow: '-moz-scrollbars-none',
    scrollbarWidth: 'none',
    '&::-webkit-scrollbar': {
      display: 'none'
     },
  }

it fixed it on all browsers

@oliviertassinari
Copy link
Member

@Umerbhat It sounds like you can submit a pull request :).

@LainC156
Copy link

LainC156 commented Jan 8, 2021

@oliviertassinari I could replicate the issue of a visible scrollbar at https://material-ui.com/demos/tabs/#automatic-scroll-buttons

Screen Shot 2019-05-20 at 8 52 19 PM

I tried cross-browser vendor prefixed styling

scrollable: {
    overflowX: 'scroll',
    /* Hidden scrollbar vendor prefixed. */
    msOverflowStyle: 'none',
    overflow: '-moz-scrollbars-none',
    scrollbarWidth: 'none',
    '&::-webkit-scrollbar': {
      display: 'none'
     },
  }

it fixed it on all browsers

this work for me, thanks

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: tabs This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants