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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tabs] Tab container won't scroll when only one tab is (partially) visible #32748

Closed
2 tasks done
frankkluijtmans opened this issue May 12, 2022 · 3 comments 路 Fixed by #32778
Closed
2 tasks done

[Tabs] Tab container won't scroll when only one tab is (partially) visible #32748

frankkluijtmans opened this issue May 12, 2022 · 3 comments 路 Fixed by #32778
Labels
bug 馃悰 Something doesn't work component: tabs This is the name of the generic UI component, not the React module! regression A bug, but worse

Comments

@frankkluijtmans
Copy link
Contributor

frankkluijtmans commented May 12, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 馃槸

I expect the Tabs container to be scrollable, also when only one tab is (partially) visible. Right now scrollable behavior is not working when the parent width is smaller than the width of a single Tab. I forked the demo CodeSandbox to illustrate the bug.

Animation2

Expected behavior 馃

The Tab container should scroll an X amount, even when the parent container cannot fit the width of a Tab.

Steps to reproduce 馃暪

Steps:

  1. Create a Tabs component that has a width <= to a single child Tab.
  2. Try scrolling using the buttons.
  3. I forked the demo CodeSandbox to illustrate the bug.

Context 馃敠

I'm trying to use scrollable Mui tabs in tight spaces where the display name of the tab also has a variable length. Sometimes this results in the tabs component having a width smaller than a single tab.

Your environment 馃寧

`npx @mui/envinfo`
  System:
    OS: Windows 10 10.0.19043
  Binaries:
    Node: 16.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.24.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Spartan (44.19041.1266.0), Chromium (101.0.1210.39)
@frankkluijtmans frankkluijtmans added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 12, 2022
@MahmoudMans
Copy link

hello @frankkluijtmans, i tested your sandbox, it seems that the error is fixed or maybe i didn't understand well the problems
here is a screen that show a tab that is partially visible but it still scrollable
image

@frankkluijtmans
Copy link
Contributor Author

frankkluijtmans commented May 15, 2022

@MahmoudMans Sorry for the unclear explanation, I also realized the CodeSandbox didn't demo this issue correct so I updated it 馃槄 The case I'm talking about here (which is admittedly a bit of an edge case) happens when the tab container is narrow enough for only 1 tab to be partially visible. Since current behavior would only scroll the container by the width of fully visible tabs, it would not scroll at all in such a case.

I took some time to create a PR with my proposed solution: #32778 . This would check if the first visible element is smaller than the tab container, and then scroll by the width of that tab. I also added a unit test to check such a case.

@oliviertassinari oliviertassinari added bug 馃悰 Something doesn't work component: tabs This is the name of the generic UI component, not the React module! regression A bug, but worse and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 馃悰 Something doesn't work component: tabs This is the name of the generic UI component, not the React module! regression A bug, but worse
Projects
None yet
3 participants