-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Inifinite loop in the scroll button logic #13699
Comments
@andrewtpoe It's not the first time we get this repport, but we couldn't reproduce it to date, if you could create a minimal reproduction example, it would help, a lot! (codesandbox can be a start). |
This is what I have, but it doesn't appear to cause the error on code sandbox. This code essentially mirrors what is causing the issue in my app though: |
@oliviertassinari - The codesandbox I've linked in the comment above has caused the error for me, though it appears to not happen regularly. In my app it happens all the time. |
This is exactly the issue we had with reproducing the bug. It's gone once put in isolation, making it very hard to debug 😞. |
Does this happen in the browser or in a unit test i.e. with jsdom? |
In the browser.
|
Having the same issue.. with v3.4.0 |
@DekelYossef Perfect. That one is reproducible for me on the initial page load. |
My guess: -if (
- showLeftScroll !== this.state.showLeftScroll ||
- showRightScroll !== this.state.showRightScroll
-) {
- this.setState({ showLeftScroll, showRightScroll });
-}
+ this.setState(state => state.showLeftScroll !== showLeftScroll || state.showRightScroll !== showRightScroll ? { showLeftScroll, showRightScroll } : null ) Same issue here https://github.com/mui-org/material-ui/blob/1c8c88781c5d48915099cf4db17f255c17b052e5/packages/material-ui/src/Tabs/Tabs.js#L281-L288 |
Tried this and it didn't work. As it stands right now its toggling Update:
Update2:
|
Wow, nice reproduction! ❤️ This is definitely an infinit loop issue, and not the first one on the tabs I look into :). The fix should be as simple as: export const styles = {
/* Styles applied to the root element. */
root: {
color: 'inherit',
- flex: '0 0 56px',
+ width: 56,
+ flexShrink: 0,
},
};
/**
* @ignore - internal component.
*/
function TabScrollButton(props) { @eps1lon What do you think? |
Thanks @DekelYossef! I'm not super familiar with Code Sandbox and didn't know you could do that. |
@oliviertassinari I noticed that my fix has some undesired side-effects so I would prefer your fix. Is that component public? If so I would add a big warning that it should have a static width. |
@eps1lon The component is private, I think that it's fine. Also, using width over flex-basis, should improve customizability. |
@issuehuntfest has funded $60.00 to this issue. See it on IssueHunt |
Expected Behavior 🤔
I am rendering a tabs component with
scrollButtons="auto"
andscrollable={true}
. The number of tabs I am rendering causes the scroll buttons to display at all times. If the initialvalue
correlates to one of the tabs hidden on first render, the tabs component should scroll to display the correct tab and show it as selected.Current Behavior 😯
I receive the following error:
Steps to Reproduce 🕹
Link: https://codesandbox.io/s/9oo90okxmo
This issue has happened for me with the code sandbox link, however, it is intermittent. It appears to happen more regularly with more (not necessarily related) elements rendered on screen. This makes me suspect a race condition somewhere, but as I'm not familiar with the library code I'll leave that to the experts for now.
Tabs
component with many tabs. Include the propsscrollButtons="auto"
andscrollable={true}
. Make sure the tabs can scroll.Tabs
component to scroll.Context 🔦
My tabs scroll. I am providing a value on render. That value may mean the Tabs component should scroll.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: