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

[material-ui][Tabs] End scroll button overlaps last tab when it is the initial value #40692

Open
kealjones-wk opened this issue Jan 19, 2024 · 7 comments
Assignees
Labels
bug 🐛 Something doesn't work component: tabs This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material regression A bug, but worse

Comments

@kealjones-wk
Copy link
Contributor

kealjones-wk commented Jan 19, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/nostalgic-fog-9z6fzy

Steps:

  1. Observe the end scroll button overlapping the initially focused tab.

Current behavior

When the initial value is the last tab of a Tabs component with a scrollable variant the end scroll button overlaps the focused tab.

  • With react-dom ^18.0.0 using ReactDOM.createRoot api (concurrent rendering), this happens but MUCH more intermittently. Hitting refresh on the sandbox demo page a few times will eventually make it happen.
  • With react-dom ^17.0.0 using legacy ReactDOM.render it happens every time.

It seems like it is a race condition between when the scrolling happens and when the scroll buttons are rendered into the dom.

Expected behavior

The end scroll button shouldn't overlap the focused tab on initial render.

Context

I am trying to make the UX of Tabs better. It has made it awkward for users to know the tab is even focused.

Pretty confident it was introduced in 5.14.2 by either:
#36071
or
#38133

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: tabs scrollable focus

@kealjones-wk kealjones-wk added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 19, 2024
@kealjones-wk kealjones-wk changed the title [material-ui][Tabs] [material-ui][Tabs] End scroll button overlaps last tab when it is the initial value Jan 19, 2024
@zannager zannager added component: tabs This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Jan 22, 2024
@trizotti
Copy link
Contributor

I'd like to help with this. Can I try to solve this issue?

@trizotti
Copy link
Contributor

I tried your code in a playground, @kealjones-wk , but it seems to be working normally, without any overlaping... Here is a gif of the page being loaded:
peek
It is the exact code you provided, but running in a development playground... I couldn't reproduce the overlap behavior...

@mnajdova mnajdova assigned michaldudak and unassigned mnajdova Jan 31, 2024
@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Feb 6, 2024

I can reproduce this, as you noted, starting from version 5.14.2.

@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work regression A bug, but worse and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 6, 2024
@kealjones-wk
Copy link
Contributor Author

kealjones-wk commented Feb 6, 2024

I just updated the issue description with some more details and an improved live example to https://codesandbox.io/p/sandbox/nostalgic-fog-9z6fzy which properly demos the issue.

While fixing the demo I noticed some things:

  • With react-dom ^18.0.0 using ReactDOM.createRoot api (concurrent rendering), this still happens but MUCH more intermittently. Hitting refresh on the sandbox demo page a few times will eventually make it happen.
  • With react-dom ^17.0.0 using legacy ReactDOM.render it happens every time.

It seems like it is a race condition between when the scrolling happens and when the scroll buttons are rendered into the dom.

@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Feb 7, 2024

With react-dom ^18.0.0 using ReactDOM.createRoot api (concurrent rendering), this still happens but MUCH more intermittently. Hitting refresh on the sandbox demo page a few times will eventually make it happen.

@kealjones-wk It does not occur intermittently for me with v18. It happens everytime. Here is the CodeSandbox using react-dom version 18.0.0: https://codesandbox.io/p/sandbox/cocky-marco-fwgy3q.

One thing I noticed is that it doesn't overlap during the initial render, meaning when I first open the CodeSandbox.

@janeisenmenger
Copy link

I am facing the same issue. I have also noticed that this behaviour (as in the overlapping) is present in the actual documentation, see here: https://mui.com/material-ui/react-tabs/#automatic-scroll-buttons.

How to reproduce:

Screenshot 2024-03-20 at 16 04 37

What I have noticed during local debugging is that even when I force a scrollIntoView on the last element, it will still be overlapped. However, delaying the scrollIntoView by half a second seems to then scroll correctly and show the last element as expected.

@kealjones-wk
Copy link
Contributor Author

Sooooooooooooo....

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! package: material-ui Specific to @mui/material regression A bug, but worse
Projects
None yet
Development

No branches or pull requests

7 participants