-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] Scrollable tabs crashes when overriding styles in theme using slots callback #38406
Comments
I ran into this as well, reading ownerState values in the theme styleOverrides for the Tabs component. Pinning |
I propose the fix like this: diff --git a/packages/mui-material/src/Tabs/Tabs.js b/packages/mui-material/src/Tabs/Tabs.js
index 12a9f9ba9f..7c93ba1186 100644
--- a/packages/mui-material/src/Tabs/Tabs.js
+++ b/packages/mui-material/src/Tabs/Tabs.js
@@ -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 Since the |
The proposed solution above works fine on my end. 👍 |
Would you like to submit a PR? |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/mui-tabs-style-override-crash-p9wfjm-p9wfjm?file=/package.json
Downgrading the package version in the live example will "fix" the error.
Steps:
Tabs
component, set its variant toscrollable
.Tabs
styling. This function uses theprops
parameter to decide which styles to apply. TheownerState.orientation
field is deconstructed out of the object.Current behavior 😯
The rendering crashes, stating that
_ref.ownerState
is undefined (where_ref
is the name of theprops
parameter after downleveling). This happens because theprops
object does not have theownerState
prop, even though its typings suggest that it does have that prop.Expected behavior 🤔
The
props
object should have theownerState
prop, as the typings describe.Context 🔦
This appears to happen because
TabsScrollbarSize
is being rendered. It uses the same style overrides as the otherTabs
components, but it does not get anownerState
prop. Thus, it is undefined.Your environment 🌎
This error started appearing during routine package upgrades. In one package, it began to occur after upgrading from
5.14.2
to5.14.4
. But in others, the upgrade to5.14.4
did not trigger the same issue, and only appeared when we forced nested dependencies to upgrade as well.We are not completely sure, but believe that it is related to
@mui/system
. Downgrading that package appears to resolve the issue on the latest version of@mui/material
.It happens in all browsers.
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: