Skip to content

Commit

Permalink
[TextField] Fix required outlined label space with no asterisk (#20715)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Apr 23, 2020
1 parent 79a29f5 commit e4e1d4e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/material-ui/src/TextField/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ const TextField = React.forwardRef(function TextField(props, ref) {
InputMore.notched = InputLabelProps.shrink;
}
if (label) {
const displayRequired = InputLabelProps?.required ?? required;
InputMore.label = (
<React.Fragment>
{label}
{required && '\u00a0*'}
{displayRequired && '\u00a0*'}
</React.Fragment>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import TextField from '@material-ui/core/TextField';

export default function OutlinedHiddenRequiredIndicator() {
return (
<TextField
label="Name"
variant="outlined"
required
InputLabelProps={{
shrink: true,
required: false,
}}
/>
);
}

0 comments on commit e4e1d4e

Please sign in to comment.