Skip to content

Commit

Permalink
[TextField] Fix placeholder issue (#7838)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Aug 19, 2017
1 parent 7abfb7b commit 688be1c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
35 changes: 23 additions & 12 deletions docs/src/pages/demos/text-fields/TextFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ class TextFields extends Component {
autoComplete="current-password"
margin="normal"
/>
<TextField
id="date"
label="From date"
type="date"
defaultValue="2017-05-24"
className={classes.textField}
margin="normal"
InputLabelProps={{
shrink: true,
}}
/>
<TextField
id="multiline-flexible"
label="Multiline"
Expand All @@ -92,17 +103,6 @@ class TextFields extends Component {
className={classes.textField}
margin="normal"
/>
<TextField
id="date"
label="From date"
type="date"
defaultValue="2017-05-24"
className={classes.textField}
margin="normal"
InputLabelProps={{
shrink: true,
}}
/>
<TextField
id="helperText"
label="Helper text"
Expand All @@ -111,11 +111,22 @@ class TextFields extends Component {
helperText="Some important text"
margin="normal"
/>
<TextField
label="With placeholder"
placeholder="Placeholder"
className={classes.textField}
/>
<TextField
label="With placeholder multiline"
placeholder="Placeholder"
multiline
className={classes.textField}
/>
<TextField
id="placeholder"
label="Label"
InputProps={{ placeholder: 'Placeholder' }}
helperText="Full width!!!"
helperText="Full width!"
fullWidth
margin="normal"
/>
Expand Down
5 changes: 3 additions & 2 deletions src/Input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export const styles = (theme: Object) => {
// Remove the padding when type=search.
appearance: 'none',
},
'label + $formControl > &': {
// Show and hide the placeholder logic
'label + $formControl &': {
'&::-webkit-input-placeholder': placeholderForm,
'&::-moz-placeholder': placeholderForm, // Firefox 19+
'&:-ms-input-placeholder': placeholderForm, // IE 11
Expand Down Expand Up @@ -162,7 +163,7 @@ export const styles = (theme: Object) => {
},
},
multiline: {
padding: `${theme.spacing.unit - 2}px 0 ${theme.spacing.unit + 1}px`,
padding: `${theme.spacing.unit - 2}px 0 ${theme.spacing.unit - 1}px`,
},
inputDisabled: {
opacity: 1, // Reset iOS opacity
Expand Down

0 comments on commit 688be1c

Please sign in to comment.