Skip to content
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] Avoid outline label CSS leak #19937

Merged
merged 4 commits into from
Mar 4, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions packages/material-ui/src/OutlinedInput/NotchedOutline.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export const styles = theme => {
easing: theme.transitions.easing.easeOut,
}),
},
/* Styles applied to the label elemement. */
legendLabel: {
paddingLeft: 5,
paddingRight: 5,
display: 'inline-block',
},
/* Styles applied to the legend element. */
legendLabelled: {
display: 'block',
Expand All @@ -46,10 +52,6 @@ export const styles = theme => {
duration: 50,
easing: theme.transitions.easing.easeOut,
}),
'& span': {
paddingLeft: 5,
paddingRight: 5,
},
},
/* Styles applied to the legend element is notched. */
legendNotched: {
Expand Down Expand Up @@ -96,7 +98,14 @@ const NotchedOutline = React.forwardRef(function NotchedOutline(props, ref) {
>
{/* Use the nominal use case of the legend, avoid rendering artefacts. */}
{/* eslint-disable-next-line react/no-danger */}
ivoiv marked this conversation as resolved.
Show resolved Hide resolved
{label ? <span>{label}</span> : <span dangerouslySetInnerHTML={{ __html: '&#8203;' }} />}
{label ? (
<span className={clsx(classes.legendLabel)}>{label}</span>
) : (
<span
className={clsx(classes.legendLabel)}
dangerouslySetInnerHTML={{ __html: '&#8203;' }}
/>
)}
</legend>
</fieldset>
);
Expand Down Expand Up @@ -126,7 +135,10 @@ const NotchedOutline = React.forwardRef(function NotchedOutline(props, ref) {
>
{/* Use the nominal use case of the legend, avoid rendering artefacts. */}
{/* eslint-disable-next-line react/no-danger */}
<span dangerouslySetInnerHTML={{ __html: '&#8203;' }} />
<span
className={clsx(classes.legendLabel)}
dangerouslySetInnerHTML={{ __html: '&#8203;' }}
/>
</legend>
</fieldset>
);
Expand Down