Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5ec4287
added fix for tabs not scrolling to correct tab issue #44211
Jayesh-11 Sep 6, 2025
c9cf1de
removed unrelated change #44211
Jayesh-11 Sep 6, 2025
f9f46d7
Merge branch 'master' into fix/tabs-not-scrolling-to-correct-tab-issue
ZeeshanTamboli Sep 8, 2025
eecfe9d
added regression for LTR/RTL horizontal and vertical
Jayesh-11 Sep 8, 2025
80373d0
added fix for rtl auto tab scroll in view
Jayesh-11 Sep 13, 2025
e67c6af
Merge branch 'master' into fix/tabs-not-scrolling-to-correct-tab-issue
ZeeshanTamboli Sep 22, 2025
c9a3ed6
prettier
ZeeshanTamboli Sep 22, 2025
6b5d7c4
Merge branch 'master' into fix/tabs-not-scrolling-to-correct-tab-issue
Jayesh-11 Sep 25, 2025
a1123b5
Merge branch 'fix/tabs-not-scrolling-to-correct-tab-issue' of github.…
Jayesh-11 Sep 27, 2025
05ab80b
added fix in accordance to the viewport shift due to scrollbuttons
Jayesh-11 Sep 27, 2025
e9ed88a
Merge branch 'master' into fix/tabs-not-scrolling-to-correct-tab-issue
Jayesh-11 Sep 27, 2025
01f78fb
Merge branch 'master' into fix/tabs-not-scrolling-to-correct-tab-issue
ZeeshanTamboli Sep 27, 2025
dc76cc2
Merge branch 'fix/tabs-not-scrolling-to-correct-tab-issue' of https:/…
ZeeshanTamboli Sep 27, 2025
6dc9c24
Fix lint
ZeeshanTamboli Sep 27, 2025
8cafe81
use scrollable
ZeeshanTamboli Sep 27, 2025
f1752dc
added explicit scrollable auto and updated file names
Jayesh-11 Sep 28, 2025
feafd74
prettier
ZeeshanTamboli Sep 28, 2025
066b4fa
Merge branch 'master' into fix/tabs-not-scrolling-to-correct-tab-issue
ZeeshanTamboli Sep 28, 2025
e8c6ad5
remove unnecessary handler and aria-label from regression test
ZeeshanTamboli Sep 28, 2025
186b877
fix typo in filename
ZeeshanTamboli Sep 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/mui-material/src/Tabs/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ const Tabs = React.forwardRef(function Tabs(inProps, ref) {
scroll(nextScrollStart, { animation });
} else if (tabMeta[end] > tabsMeta[end]) {
// right side of button is out of view
const nextScrollStart = tabsMeta[scrollStart] + (tabMeta[end] - tabsMeta[end]);
const nextScrollStart =
tabsMeta[scrollStart] + (tabMeta[end] - tabsMeta[end]) + tabMeta[size];
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli Sep 13, 2025

Choose a reason for hiding this comment

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

Should we consider the similar size like here if left-side button is out of view as well, in the earlier above if condition?

scroll(nextScrollStart, { animation });
}
});
Expand Down
32 changes: 32 additions & 0 deletions test/regressions/fixtures/Tabs/LTRHorizontalTabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';

export default function LTRHorizontalTabs() {
const [value, setValue] = React.useState(4);

const handleChange = (event, newValue) => {
setValue(newValue);
};
return (
<Box sx={{ width: 300, display: 'flex' }}>
<Tabs
value={value}
variant="scrollable"
scrollButtons
orientation="horizontal"
onChange={handleChange}
aria-label="scrollable auto tabs example"
>
<Tab label="Tab A" />
<Tab label="Tab B" />
<Tab label="Tab C" />
<Tab label="Tab D" />
<Tab label="Tab E" />
<Tab label="Tab F" />
<Tab label="Tab G" />
</Tabs>
</Box>
);
}
32 changes: 32 additions & 0 deletions test/regressions/fixtures/Tabs/LTRVerticalTabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';

export default function LTRVerticalTabs() {
const [value, setValue] = React.useState(4);

const handleChange = (event, newValue) => {
setValue(newValue);
};
return (
<Box sx={{ height: 200, display: 'flex' }}>
<Tabs
value={value}
variant="scrollable"
scrollButtons
orientation="vertical"
onChange={handleChange}
aria-label="scrollable auto tabs example"
>
<Tab label="Tab A" />
<Tab label="Tab B" />
<Tab label="Tab C" />
<Tab label="Tab D" />
<Tab label="Tab E" />
<Tab label="Tab F" />
<Tab label="Tab G" />
</Tabs>
</Box>
);
}
38 changes: 38 additions & 0 deletions test/regressions/fixtures/Tabs/RTLHorizontalTabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as React from 'react';
import { prefixer } from 'stylis';
import rtlPlugin from '@mui/stylis-plugin-rtl';
import { CacheProvider } from '@emotion/react';
import createCache from '@emotion/cache';
import { StyleSheetManager } from 'styled-components';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';

// Create rtl cache
const cacheRtl = createCache({
key: 'muirtl',
stylisPlugins: [prefixer, rtlPlugin],
});

export default function RTLHorizontalTabs() {
return (
<StyleSheetManager stylisPlugins={[rtlPlugin]}>
<CacheProvider value={cacheRtl}>
<ThemeProvider theme={createTheme({ direction: 'rtl' })}>
<Box dir="rtl" sx={{ width: 300, display: 'flex' }}>
<Tabs value={2} variant="scrollable" scrollButtons orientation="horizontal">
<Tab label="Tab A" />
<Tab label="Tab B" />
<Tab label="Tab C" />
<Tab label="Tab D" />
<Tab label="Tab E" />
<Tab label="Tab F" />
<Tab label="Tab G" />
</Tabs>
</Box>
</ThemeProvider>
</CacheProvider>
</StyleSheetManager>
);
}
Loading