Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions examples/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"@babel/plugin-proposal-class-properties": "latest",
"@babel/preset-env": "latest",
"@babel/preset-react": "latest",
"@material-ui/core": "next",
"@material-ui/styles": "next",
"@material-ui/core": "latest",
"@material-ui/styles": "latest",
"babel-loader": "latest",
"express": "latest",
"nodemon": "latest",
Expand Down
10 changes: 3 additions & 7 deletions packages/material-ui/src/Tabs/ScrollbarSize.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ const styles = {
position: 'absolute',
top: -9999,
overflow: 'scroll',
// TODO Do we need this style for IE 11 support?
msOverflowStyle: 'scrollbar',
};

/**
* @ignore - internal component.
* The component is originates from https://github.com/STORIS/react-scrollbar-size.
* It has been moved into the core in order to minimize the bundle size.
*/
function ScrollbarSize(props) {
const { onChange } = props;
export default function ScrollbarSize(props) {
const { onChange, ...other } = props;
const scrollbarHeight = React.useRef();
const nodeRef = React.useRef(null);

Expand Down Expand Up @@ -49,11 +47,9 @@ function ScrollbarSize(props) {
onChange(scrollbarHeight.current);
}, [onChange]);

return <div style={styles} ref={nodeRef} />;
return <div style={styles} ref={nodeRef} {...other} />;
}

ScrollbarSize.propTypes = {
onChange: PropTypes.func.isRequired,
};

export default ScrollbarSize;
35 changes: 20 additions & 15 deletions packages/material-ui/src/Tabs/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export const styles = theme => ({
/* Styles applied to the tablist element if `variant="scrollable"`. */
scrollable: {
overflowX: 'scroll',
// Hide dimensionless scrollbar on MacOS
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to write this style when this.state.scrollerStyle.marginBottom === 0? As this will hide scrollbar on Windows also but won't create an issue

Copy link
Member

@oliviertassinari oliviertassinari May 25, 2019

Choose a reason for hiding this comment

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

This is only necessary for MacOS when the scrollbar is configured to have no dimensions. We don't need it on Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am sorry, tell me if I am correct. Right now the code is still running for Windows. To make it run only on MacOS I think we need to check if scroll Dimension is 0 using this check this.state.scrollerStyle.marginBottom === 0

Copy link
Member

Choose a reason for hiding this comment

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

Why is this a problem?

scrollbarWidth: 'none', // Firefox
'&::-webkit-scrollbar': {
display: 'none', // Safari + Chrome
},
},
/* Styles applied to the `ScrollButtonComponent` component. */
scrollButtons: {},
Expand Down Expand Up @@ -118,7 +123,7 @@ class Tabs extends React.Component {
const conditionalElements = {};
const scrollable = variant === 'scrollable';
conditionalElements.scrollbarSizeListener = scrollable ? (
<ScrollbarSize onChange={this.handleScrollbarSizeChange} />
<ScrollbarSize className={classes.scrollable} onChange={this.handleScrollbarSizeChange} />
) : null;

const scrollButtonsActive = showLeftScroll || showRightScroll;
Expand Down Expand Up @@ -305,7 +310,7 @@ class Tabs extends React.Component {
centered,
children: childrenProp,
classes,
className: classNameProp,
className,
component: Component,
indicatorColor,
innerRef,
Expand All @@ -328,15 +333,6 @@ class Tabs extends React.Component {
'at the same time on a `Tabs` component.',
);

const className = clsx(classes.root, classNameProp);
const flexContainerClassName = clsx(classes.flexContainer, {
[classes.centered]: centered && !scrollable,
});
const scrollerClassName = clsx(classes.scroller, {
[classes.fixed]: !scrollable,
[classes.scrollable]: scrollable,
});

const indicator = (
<TabIndicator
className={classes.indicator}
Expand Down Expand Up @@ -382,19 +378,28 @@ class Tabs extends React.Component {
const conditionalElements = this.getConditionalElements();

return (
<Component className={className} ref={innerRef} {...other}>
<Component className={clsx(classes.root, className)} ref={innerRef} {...other}>
<EventListener target="window" onResize={this.handleResize} />
{conditionalElements.scrollbarSizeListener}
<div className={classes.flexContainer}>
{conditionalElements.scrollButtonLeft}
{conditionalElements.scrollbarSizeListener}
<div
className={scrollerClassName}
className={clsx(classes.scroller, {
[classes.fixed]: !scrollable,
[classes.scrollable]: scrollable,
})}
style={this.state.scrollerStyle}
ref={this.handleTabsRef}
role="tablist"
onScroll={this.handleTabsScroll}
>
<div className={flexContainerClassName}>{children}</div>
<div
className={clsx(classes.flexContainer, {
[classes.centered]: centered && !scrollable,
})}
>
{children}
</div>
{this.state.mounted && indicator}
</div>
{conditionalElements.scrollButtonRight}
Expand Down