-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Conversation
Wow very nice @fredriklindell 👍 👍 Thanks a lot. any chance you could also add an example in the docs site explicitly for this behavior? |
@fredriklindell That looks like good start 👍. |
@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? |
@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, |
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.
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.
That sounds like a good idea 👍. |
@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. |
I see that you have pushed the code, I will try to have a look. |
@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. |
a084f7c
to
7146329
Compare
@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. |
@oliviertassinari have you had any time to look at the PR? Thanks in advance. |
@fredriklindell Great work!! |
@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 👍 |
@oliviertassinari Any update on this PR? Do I need to compliment anything? Thanks in advance! |
@alitaheri No worries, I will see what I can do tonight :) |
@fredriklindell Sorry for not catching up earlier. I have various comments on this PR 👍
|
}, | ||
|
||
handleWindowWidthChange() { | ||
this.replaceState(this.getNewState()); |
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.
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
120ba83
to
a1e02e1
Compare
* 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
@oliviertassinari Will this PR get merged? |
@vishalvijay We have agreed on splitting this PR into two chunks:
|
@oliviertassinari Somebody working on the same or I can give a try? |
@vishalvijay Said that he is off for two weeks. If you can give it try, that would be awesome 👍. |
I'm continuing this work. Nobody else pick this up please 😅 |
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 :-) |
@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 👍 |
@mbrookes This is PR: On Hold but is on the |
@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. 😁 |
@alitaheri Ok, awesome! 👍 |
@alitaheri What's the progress on this? We need it in our app, so I wouldn't mind helping if you need it 😄 |
@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. |
@alitaheri Gonna finish this or want to close? |
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. |
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.