-
-
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
[TextField] sx
prop does not exist in slotProps.input
#45041
Comments
Hey @andreievg! Thanks for reaching out. To merge Let me know if that works! 😊 |
@DiegoAndai thanks. There is not mergeSlotProps export @mui/material/utils https://github.com/mui/material-ui/blob/afd551abd3be44de711d6baef48e62e18b97c908/packages/mui-material/src/utils/index.d.ts#L1-L20 There is one in @mui/mui
material-ui/packages/mui-base/src/utils/mergeSlotProps.ts Lines 60 to 69 in afd551a
Not really sure how to use it in my case (where there is a wrapper component), thanks for your help in advanced |
@DiegoAndai This is what happen currently: // user create a TextField wrapper
const Wrapper: typeof TextField = ({ slotProps, ...props }) => (
<TextField
slotProps={{
input: mergeSlotProps(slotProps?.input, {
sx: { borderRadius: "10px" },
}),
}}
{...props}
/>
);
// usage of the wrapper
function App() {
return (
<div>
<div className="App">
<Wrapper
slotProps={{
input: {
sx: { // this `sx` will replace { borderRadius: "10px" }
color: "red",
},
},
}}
/>
</div>
</div>
);
} The final result will be color red without border radius |
sx
prop does not exist in slotProps.input
Steps to reproduce
Steps:
yarn && yarn tsc -b
with this commit: andreievg/mui-6-typescript@c280b19 (no typescript errors)yarn && yarn tsc -b
with this commit: andreievg/mui-6-typescript@1372caf (see typescript error)Current behavior
After upgrading to MUI 6 from MUI 5 typescript is confused about
sx
missing on slotProps.input, previously it was in InputProps, and typescript didn't complaintbefore, in MUI 5 (https://github.com/andreievg/mui-6-typescript/blob/c280b19a3ceac5451b4d93a496b6e219f9c9e1d7/src/App.tsx#L4-L12)
after, in MUI 6 (https://github.com/andreievg/mui-6-typescript/blob/1372caf7ac510e95046289c1df75a9fe62ed1b5c/src/App.tsx#L4-L14)
getting this error
Expected behavior
upgrade form MUI 5 to MUI 6 doesn't break type safety (when upgrading deprecated api)
Context
upgrade form MUI 5 to MUI 6
Your environment
npx @mui/envinfo
Search keywords: sx slotProps.input MUI6
The text was updated successfully, but these errors were encountered: