-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Revert visual regressions from #42283 #43364
[material-ui] Revert visual regressions from #42283 #43364
Conversation
Netlify deploy previewhttps://deploy-preview-43364--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
@@ -37,7 +37,9 @@ const TextFieldRoot = styled(FormControl, { | |||
name: 'MuiTextField', | |||
slot: 'Root', | |||
overridesResolver: (props, styles) => styles.root, | |||
})({}); | |||
})({ | |||
maxWidth: '100%', |
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.
What is the reasoning behind adding this to TextField
vs. FormControl
vs. InputBase
? I'm not fully familiar with this abstraction hierarchy.
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.
We want maxWidth: 100%
to be applied directly to the TextField
root because it's the component that's immediately impacted by the container's size. While you might consider applying it to FormControl
, which TextField
inherits, FormControl
is primarily responsible for form-related context (like labels and helper text) which Text field also supports and not for the direct sizing or spacing of TextField
. Adding maxWidth: 100%
to FormControl
could create unintended side effects for other form controls.
As for InputBase
, it's used by other components like Select
. Applying maxWidth: 100%
there would impact all components that rely on InputBase
, potentially causing layout issues where this behavior isn't needed. And it won't even fix the issue because it is not a direct child of the container.
TextField
is a higher-level component that combines InputBase
and FormControl
, providing a simplified API for common use cases.
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.
Thanks for the explanation
@ZeeshanTamboli the after fix codesanbox seems to be private |
As usual, forgot to make it public 😓. Should be visible now. |
To be honest, I'd revert some of the changes in #42283 (InputBase and StepLabel). Because it's hard to justify which one is a bug. You might say this PR is a fix but it could be a regression for users who want to control the width larger than the container. Now the code below does not work due to <div style={{ width: 200 }}>
<TextField sx={{ width: 300 }} />
</div> or we don't merge this PR and add to the migration guide that the TextField has an implicit width. To make it follow the container, add |
Agree, if these changes introduced any perceived changes for people we should revert them. |
I think such cases would be rare, but you might be right. Users can override it with <div style={{ width: 200 }}>
<TextField sx={{ width: 300, maxWidth: 'none' }} />
</div> However, this adds an extra step, which could make them see it as a regression. I believe |
I agree with @siriwatknp and @mnajdova, let's revert the changes. The intent of the PR was to remove IE-11-only code, but if that creates changes in other browsers, then it shouldn't be there. I understand we could discuss if " @siriwatknp why do you think we should also include the |
The removal of There is no reported issue yet, just to prevent it. |
Alright. I agree, it shouldn't block the release. I'll let you handle this PR since you pushed the commit. |
@aarongarciah @siriwatknp ready for review |
Closes #43185
The regression was introduced in this change in PR #42283, wherewidth: 100%
was replaced withflexGrow: 1
in InputBase affecting theTextField
component. The replacement was correct becauseflexGrow: 1
allows the input to take up remaining space in the flexbox layout when there are start or end adornments. The originalwidth: 100%
was a workaround for IE compatibility.However, removingwidth: 100%
caused theTextField
to overflow its container, as it no longer adhered to the container's width. Earlier, withwidth: 100%
on input, the custom container with a defined width rendered by the user became the closest ancestor for input width calculation, leading to it adjusting according to the container width.Solution: AddingmaxWidth: 100%
to theTextField
root ensures it stays within its container's boundaries without overflowing when the container is smaller. In case where the container is larger than the TextField, the TextField won't expand to fill the container and for that thefullWidth
prop can be used when theTextField
should occupy the full container width.I've also added a visual regression test to prevent similar issues in the future.Before: CodeSandboxAfter Fix: CodeSandbox
Edit: See the discussion in PR. We are reverting some changes done in #42283