-
-
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
[material-ui][Input] Remove unused classes from InputClasses interface #44987
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy previewhttps://deploy-preview-44987--material-ui.netlify.app/ Bundle size report |
/** Styles applied to the root element if the component is focused. */ | ||
focused: string; | ||
/** Styles applied to the root element if `disabled={true}`. */ | ||
disabled: string; | ||
/** Styles applied to the root element if color secondary. */ | ||
colorSecondary: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding the class to the DOM, I chose to remove it here. The fact that no users have reported this issue, even though it has likely existed for a long time (possibly since v5), suggests that it is not widely used. Therefore, I decided to remove the class instead of adding it to the DOM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sai6855 I see there are several unused classes in the Input
component, such as sizeSmall
, inputSizeSmall
, multiline
, inputMultiline
, inputAdornedStart
and others. Only these classes are actually used: root
, focused
, error
, disabled
, underline
, and input
.
Thanks!! Yeah you are right, removed all usused classes and added tests to verify same |
@sai6855 I looked into the history of this and found that The utility classes are passed to the
Additionally, the
This applies to FilledInput and OutlinedInput as well. For example, in #31080, it was expected that styles for Input with multiline are applied using inputClasses.multiline instead of inputBaseClasses.multiline , even though the actual DOM classname is MuiInputBase-multiline . This was fixed in #31186.
I think this PR should be closed, as removing these classes would introduce a breaking change. |
@ZeeshanTamboli i agree it's a breaking change if classes are removed, what do you think of last 2 commits? it keeps class in interface but removes info from docs so that users cannot see wrong info on classes |
@sai6855 If those class names are still used for styling, why remove them from the docs? |
take this class for example https://mui.com/material-ui/api/input/#input-classes-MuiInput-colorSecondary From user pov, user sees this class and tries to style using this class but it doesn't work because this class doesn't exist. so removing this info makes sense know? |
It does work. Check this example: https://codesandbox.io/p/sandbox/purple-violet-sgk8hf. Type in the input, and you'll see the text color is red. Although the DOM shows the class as It's what I said in #44987 (comment) that the classes are forwarded to the |
I think there is slight misunderstanding going on here, provided example works because it is using this commit 89a2570 removes below info from docs which is saying to use I tried to demonstrated same in this demo https://stackblitz.com/edit/react-2kfct41z?file=Demo.tsx |
@sai6855 Ah, I see now. I was confused about how So, it makes sense to remove it from the docs. Alternatively, we could mark it as deprecated since developers are already using it. Either way, we should get a review from @DiegoAndai on this. |
@DiegoAndai Here's the summary of above discussion There are several classes in proof for This PR aims to remove any information regarding unused classes, we could try 2 ways to solve this
which approach do you suggest? |
This PR removes unused classes from InputClasses interface, removed classes doesn't actually end up in dom and just present in interface, added tests to verify same
I found this while working on deprecating composed classes for Input component