-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Tabs] Add scrollable behavior #6502
Conversation
The PR is failing on the vrtest run. I'm not really sure what to do about it since I'm not familiar with that tool and the docs seem to be wip. |
@shawnmcknight Hey, thanks for working on that feature! The UX is pretty cool 😍 . I have only noticed one issue so far, the demo do not render well on mobile (too large). |
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.
The overall implementation looks rock solid. Good work guys!
|
||
const styleSheet = createStyleSheet('ScrollableTabsButtonAuto', (theme) => ({ | ||
root: { | ||
width: 500, |
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.
I would use width: '100%'
for all the example (to address the small width issue).
index={this.state.index} | ||
onChange={this.handleChange} | ||
scrollable | ||
scrollButtons={'auto'} |
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.
scrollButtons="auto"
textColor="accent" | ||
> | ||
<Tab | ||
label="Item One" |
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.
I think that having the component on a single line would be better. At least our current rule is we stick 3 props then break it into different lines.
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.
Maybe you should consider using https://github.com/prettier
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.
@stunaz I looked at it a while back, and it was just too rigid / opinionated.
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.
Isn't what we are looking for, something rigid and opinionated to focus on something else?
index={this.state.index} | ||
onChange={this.handleChange} | ||
scrollable | ||
scrollButtons={'on'} |
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.
scrollButtons="on"
scrollButtons={'off'} | ||
> | ||
<Tab | ||
icon={<PhoneIcon />} |
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.
Single line, the shorter the demos are the better.
src/Tabs/Tabs.js
Outdated
const { | ||
buttonClassName, | ||
scrollable, | ||
scrollButtons: scrollButtonsProp, |
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.
renaming the property to scrollButtonsProp
seems point less.
src/Tabs/Tabs.js
Outdated
fullWidth, | ||
index, | ||
indicatorClassName, | ||
indicatorColor, | ||
onChange, | ||
scrollable, // eslint-disable-line no-unused-vars | ||
scrollButtons: scrollButtonsProp, // eslint-disable-line no-unused-vars |
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.
renaming the property to scrollButtonsProp
seems point less.
src/Tabs/Tabs.js
Outdated
showScrollButtons ? ( | ||
<TabScrollButton | ||
className={buttonClassName} | ||
direction={'right'} |
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.
direction="right"
src/Tabs/Tabs.js
Outdated
conditionalElements.scrollButtonLeft = ( | ||
showScrollButtons ? ( | ||
<TabScrollButton | ||
direction={'left'} |
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.
direction="left"
|
||
handleScrollbarSizeChange = ({ scrollbarHeight }) => { |
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.
Sounds like it's for supporting Windows 👍 .
@oliviertassinari I believe I've got everything you requested other than the dive() update. I tried for a while to get it working, but I was unable to get the shallow rendered withWidth() to let me find() or dive() or really anything at all. Any thoughts and/or advice on how to get this functional? I'll definitely update the tests to use it if I can get something working with it. I'm also continuing to get the failure from the vrtest tool. I had attempted to get something added for this, but ran into problems with test:regressions. I had logged #6518 for that, but haven't heard anything so I'm stuck on that as well. If you could point me in a direction I can hopefully get this PR wrapped up. Thanks! |
I'm gonna have a look at it, thanks! I'm wondering what's going on with the vrtest.
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.
Some last small things. It's close to be merged 😄 .
// @flow weak | ||
/* eslint-disable react/no-multi-comp */ | ||
|
||
import React, { Component, PropTypes } from 'react'; |
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.
Could you rebase the branch on next
we started the migration to use the prop-types
packages.
src/svg-icons/keyboard-arrow-left.js
Outdated
@@ -0,0 +1,15 @@ | |||
/* eslint-disable */ |
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.
I have updated the format, please rebase, here is an example of what it looks like now. I have just disabled some eslint rules instead of all of them, it's safer that way.
// @flow weak
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../SvgIcon';
let CheckBox = (props) => (
<SvgIcon {...props}>
<path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" />
</SvgIcon>
);
CheckBox = pure(CheckBox);
CheckBox.muiName = 'SvgIcon';
export default CheckBox;
Regarding the vrtest issue, I can always run the visual regression tests locally. |
@shawnmcknight When you get a moment, please could you update https://github.com/callemall/material-ui/blob/next/docs/src/pages/getting-started/supported-components.md as part of this PR? |
- Rebase/syntax requests - Support components docs - vrtest baseline image update
Visible now has a default propType of true and the not visible test requires an explicit declaration of false.
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.
😍
@shawnmcknight Thanks a lot, I'm glad @STORIS is investing on the project 🙏 . |
PS. Your website is down. 😱 |
This actually broke tabs for me. Unfortunately I don't have time right now to make a reproducible example, but the fix is to check for this.tabs in updateScrollButtonState same as it's done in updatePositionStates. Thanks. |
It's not immediately clear to me why that would be the case. Under what scenario are you ending up in There shouldn't be any harm caused by adding a check for |
@shawnmcknight |
I've been able to duplicate the issue, but not exactly the way described. I must put the tabs in a dialog, the tabs must be scrollable, and I must have scrolled the tabs. After that, dismissing the dialog will throw an error. The issue seems to be due to events firing on a component that is in the process of being unmounted. The browser ends up firing events on something that has been dropped out of scope. We'd hide all of that nastiness by checking for I'll log an issue and get something comprehensive in place to improve performance while fixing the thrown error. |
Thanks. Also I don't think that function should be called if |
I don't know if it's related but I have noticed one issue with how the throttle is handle. We need to cancel it during the unmount, here is an example. |
@oliviertassinari There's a very good chance it's related, and might solve the null variable issue all on its own. I'd still like to improve the lifecycle handling to prevent unnecessary activity in the component, but the throttle cancel is probably a good start to addressing the issue. @ArsenyYankovsky I'll get working on it asap, but I don't know how the PR will coincide with the timing of the next alpha release. |
Impression of déjà vu 😄 . Regarding the releases of the next branch, we are doing them frequently, every week or so. |
This PR adds the scrolling behavior requested in #4795 for both scrolling and arrows. Closes #1148.
Scrolling is treated as an opt-in prop and arrow button behavior can be customized to work automatically based on viewport size or forced on or off. Doc demos have been updated to show the various possibilities. Tests have been added and code coverage of module is at 100%.