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

[Feature] Scrollable tabs #2861

Closed

Conversation

fredriklindell
Copy link
Contributor

This commit implements request in below issue:

#1148

When device width is less than 992 tabs will paginate if the tab
container width is wider than device sreen width.

@alitaheri
Copy link
Member

Wow very nice @fredriklindell 👍 👍 Thanks a lot. any chance you could also add an example in the docs site explicitly for this behavior?

@oliviertassinari
Copy link
Member

@fredriklindell That looks like good start 👍.
Yes, could you add a new example of this so people know how to use it and to prevent regression.
Could you also fix the regression on the existing examples?
Before:
capture d ecran 2016-01-10 a 14 57 48

After:
capture d ecran 2016-01-10 a 14 51 12
Thanks!

@oliviertassinari oliviertassinari added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Jan 10, 2016
@fredriklindell
Copy link
Contributor Author

@oliviertassinari ofc i can fix a new example. Not sure what to add though, since the implementation works for above on small screens. I could add an example with more tabs - i'll do that :) what do you mean with regression, do you mean that the tab should stretch to fill the width? I could change to default prop for stretch to true, now it is false, should I do that?

@fredriklindell
Copy link
Contributor Author

@oliviertassinari alright, thank you for the explaination. I changed the Tabs default prop to stretch by default. However doing so I noticed that the examples break. Due to that the widths of the html elements in componentDidMount is not correct. If a resize is triggered everything is working, it is just the initial state. No sure if it has to do with the CodeExample component. I have to investigate a bit more. Do you have any ideas? :)

I also added an example with 12 tabs.

],

getDefaultProps() {
return {
initialSelectedIndex: 0,
stretchTabContainer: false,
Copy link
Member

Choose a reason for hiding this comment

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

should be true by default to not introduce breaking changes.
It could be changed later, with v0.15.0 if you think it's better this way.

@oliviertassinari
Copy link
Member

I also added an example with 12 tabs.

That sounds like a good idea 👍.

@fredriklindell
Copy link
Contributor Author

@oliviertassinari Correct, I have changed it to true.

But before I commit I need to fix the initial rendering error i am seeing in the examples. The widths read in componentDidMount is not correct. When I try this in my app it works. I have tried wrapping the code in my app with the ClearFix component - but it still works.

Any ideas? If you try by yourself you will notice that the ink-bar is not rendered correct. I think I need some help with this.

@oliviertassinari
Copy link
Member

Any ideas?

I see that you have pushed the code, I will try to have a look.

@fredriklindell
Copy link
Contributor Author

@oliviertassinari and regarding the possibility to change back to true in 0.15 sounds good, because the calculated width when stretching the tabs might not be equal to the width of the actual DOM element, thus making the ink-bar a bit offline to the tab.

@fredriklindell fredriklindell force-pushed the feature-scrollable-tabs branch from a084f7c to 7146329 Compare January 13, 2016 17:58
@fredriklindell
Copy link
Contributor Author

@oliviertassinari I have uploaded a new commit which somewhat fixes the problem. However, the strange thing is that the DOM elements are rendered with different widths between page reloads, it switched between two values with a rate of 50%. As I said I do not see these problems in my application only in the example page.

@fredriklindell
Copy link
Contributor Author

@oliviertassinari have you had any time to look at the PR?

Thanks in advance.

@vishalvijay
Copy link
Contributor

@fredriklindell Great work!!
@oliviertassinari When will this feature get released, waiting for it.

@alitaheri
Copy link
Member

@fredriklindell We are very sorry it took so long. But there were a lot of things we had to take care of. There were a bunch of other features added to tabs so this needs rebasing. If you don't have the time to work on this, i can take it from here. Thanks for working on this 👍

@fredriklindell
Copy link
Contributor Author

@oliviertassinari Any update on this PR? Do I need to compliment anything?

Thanks in advance!

@fredriklindell
Copy link
Contributor Author

@alitaheri No worries, I will see what I can do tonight :)

@oliviertassinari
Copy link
Member

@fredriklindell Sorry for not catching up earlier. I have various comments on this PR 👍

  • The existing examples shouldn't change from what is now and independently of the screen size.
  • Having a look at the specification here (https://www.google.com/design/spec/components/tabs.html#tabs-usage). I think that it would be good to add a scrollable boolean property. It would be false by default to not break the existing examples. When true, the width of the tab won't try to expand.
  • I feel like it's highly increasing the complexity of the Tabs and Tab components. I'm wondering if we can't move it to a new component. (That remember me this PR [AppBar] waterfall behaviour #1321).
  • The scrollable feature doesn't work on mobile devices, this don't have to be implemented in this PR, but I'm wondering how we would implement it once this PR is merged.
  • I think that it would be great to have this feature, I guess this can be done in another PR:
    janv 30 2016 12 57

},

handleWindowWidthChange() {
this.replaceState(this.getNewState());
Copy link
Member

Choose a reason for hiding this comment

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

Can we not use replaceState?

This method is not available on ES6 class components that extend React.Component. It may be removed entirely in a future version of React.

This commit implements request in below issue:

mui#1148

When device width is less than 992 tabs will paginate if the tab
container width is wider than device sreen width.
This commit implements request in below issue:

mui#1148

When device width is less than 992 tabs will paginate if the tab
container width is wider than device sreen width.
Build and document error fixes
* New scrollable tab example added
* Fix for (at least 50% of the time) for calculating widths in
  componentDidMount via requestAnimationFrame. But still the tab
  container width differs between reloads.
* Fixed for timing issue when components render, solves DOM
  element width problems.
* Rebase changes
@fredriklindell fredriklindell force-pushed the feature-scrollable-tabs branch from 120ba83 to a1e02e1 Compare January 30, 2016 21:23
* Changes according to comments
* Tabs does not consider device screen size anymore. Pagination
  will occur when tab container width is less than the total width
  of the tabs
* Changed prop value stretchTabContainer to fillWidth

Change-Id: Id63a096ab5d64ac90cccc000eab4b2811adfa043
@vishalvijay
Copy link
Contributor

@oliviertassinari Will this PR get merged?

@oliviertassinari
Copy link
Member

@vishalvijay We have agreed on splitting this PR into two chunks:

  • The first one is to implement a new propertyfillWidth. The default value would be false to keep the existing behavior.
  • The second one for implementing the overflow behavior.

@vishalvijay
Copy link
Contributor

We have agreed on splitting this PR into two chunks

@oliviertassinari Somebody working on the same or I can give a try?

@oliviertassinari
Copy link
Member

@vishalvijay Said that he is off for two weeks. If you can give it try, that would be awesome 👍.

@mbrookes mbrookes added the new feature New feature or request label Mar 5, 2016
@alitaheri
Copy link
Member

I'm continuing this work. Nobody else pick this up please 😅

@fredriklindell
Copy link
Contributor Author

Hi @alitaheri, when I left for vacation three weeks ago there where problem with the new tab implementation using enhanced button. I think that, if not already solved, we should have a look on that component and why the text is allowed to be wider that the button. If you ask me, the button size should adjust to the text width, just like a normal html button does. I highlighted this problem, but have not had the time to look intuit any further. Not sure what has happened in the main report since then, probably a lot :-)

@alitaheri
Copy link
Member

@fredriklindell Yeah, a lot has changed. that's why I'm going to break down your PR into smaller ones and see if I can extract the logic into another component. This is a great feature 👍 I really need it in my app 😅 So I'll take it from here 👍

@oliviertassinari oliviertassinari added the on hold There is a blocker, we need to wait label Mar 12, 2016
@mbrookes mbrookes added this to the 0.15.0 Release milestone Mar 14, 2016
@nathanmarks
Copy link
Member

@mbrookes This is PR: On Hold but is on the 0.15.0 release milestone, which isn't ideal 😄 What's the actual status?

@alitaheri
Copy link
Member

@nathanmarks It's on hold because I'm working on it and this is just a place holder. I'm sure I can get it in the 0.15.0 release. 😁

@nathanmarks
Copy link
Member

@alitaheri Ok, awesome! 👍

@aviraldg
Copy link

aviraldg commented Apr 9, 2016

@alitaheri What's the progress on this? We need it in our app, so I wouldn't mind helping if you need it 😄

@alitaheri
Copy link
Member

@aviraldg We do too, but I got a bit caught up with life, I plan on continuing the work on this in a couple of days. Although if you need this fast there are a couple of areas that should be fixed before this feature can be cleanly implemented.

First of all, The InkBar should not rely on the assumption that all tabs are of the same size, it should rely on the calculated width of each tab. After this, Tabs will need to be patched to work with the InkBar.

fillWidth for the Tabs should be implemented.

And then another component that wraps the Tabs should be implemented to provide the logic for this feature. it's not easy to migrate this after all the changes that happened. That's why it will probably need a re-implementation.

I would spend time to get this in. But recently I got too busy with life.

@nathanmarks
Copy link
Member

@alitaheri Gonna finish this or want to close?

@alitaheri
Copy link
Member

Man this was so hard to migrate after all the change that I couldn't even understand the old code. I gave up on it after I got busy. We still need this feature in our app though -_- I guess I'll have to implement it from scratch when we get there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request on hold There is a blocker, we need to wait PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants