Skip to content

Commit

Permalink
[Tabs] Scrollable tabs shouldn't crash when customizing their styles …
Browse files Browse the repository at this point in the history
…in the theme with slot callbacks (#38544)

Co-authored-by: ZeeshanTamboli <[email protected]>
  • Loading branch information
brentertz and ZeeshanTamboli authored Sep 11, 2023
1 parent f22e995 commit 449d6ed
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
5 changes: 1 addition & 4 deletions packages/mui-material-next/src/Tabs/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ const TabsIndicator = styled('span', {
}),
}));

const TabsScrollbarSize = styled(ScrollbarSize, {
name: 'MuiTabs',
slot: 'ScrollbarSize',
})({
const TabsScrollbarSize = styled(ScrollbarSize)({
overflowX: 'auto',
overflowY: 'hidden',
// Hide dimensionless scrollbar on macOS
Expand Down
5 changes: 1 addition & 4 deletions packages/mui-material/src/Tabs/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,7 @@ const TabsIndicator = styled('span', {
}),
}));

const TabsScrollbarSize = styled(ScrollbarSize, {
name: 'MuiTabs',
slot: 'ScrollbarSize',
})({
const TabsScrollbarSize = styled(ScrollbarSize)({
overflowX: 'auto',
overflowY: 'hidden',
// Hide dimensionless scrollbar on macOS
Expand Down
31 changes: 31 additions & 0 deletions packages/mui-material/src/Tabs/Tabs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,37 @@ describe('<Tabs />', () => {
});
expect(tablistContainer.style.overflow).to.equal('');
});

it('should handle theme styleOverrides for scrollable tabs without crashing', () => {
const theme = createTheme({
components: {
MuiTabs: {
styleOverrides: {
root: ({ ownerState: { orientation } }) => ({
...(orientation === 'vertical'
? {
background: 'magenta',
}
: {
background: 'lime',
}),
}),
},
},
},
});

expect(() =>
render(
<ThemeProvider theme={theme}>
<Tabs sx={{ width: 200 }} value={0} variant="scrollable">
<Tab label="First" />
<Tab label="Second" />
</Tabs>
</ThemeProvider>,
),
).not.to.throw();
});
});

describe('prop: !variant="scrollable"', () => {
Expand Down

0 comments on commit 449d6ed

Please sign in to comment.