-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Make it meet guidelines #6566
Changes from 1 commit
7f966d0
10a5c0f
6e8ad06
b5fb82a
6cece85
7b7fa13
4716659
6f83e5b
186a251
7abcec9
d02154c
dffc976
890217f
0b15230
f27ea99
b11a2e8
7a3d1f4
710e605
ff1abe5
0061db1
6af7c88
0565e94
c3bde34
c740da2
760eb25
4e16f7c
e7e7f47
38d4043
2f70c6c
1457b96
5fe667a
5d6970d
612b02c
ae3d010
3cd4b99
9b40eee
428d870
489de60
a8a9a6c
3043877
f30dbea
0419922
c37fe6e
30be343
60ae4d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ export const styleSheet = createStyleSheet('MuiFormControl', () => { | |
root: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
marginBottom: 8, | ||
marginTop: 16, | ||
position: 'relative', | ||
}, | ||
row: { | ||
|
@@ -55,10 +57,19 @@ export default class FormControl extends Component { | |
muiFormControl: PropTypes.object.isRequired, | ||
}; | ||
|
||
state = { | ||
dirty: false, | ||
focused: false, | ||
}; | ||
constructor(props, context) { | ||
super(props, context); | ||
|
||
const dirty = props.children.some((child) => { | ||
return child.type && child.type.name === 'Input' && | ||
child.props.value && child.props.value.length > 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about importing the |
||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks complex. Any better way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question! I can't think of a better alternative 🤔 . |
||
|
||
this.state = { | ||
dirty, | ||
focused: false, | ||
}; | ||
} | ||
|
||
getChildContext() { | ||
const { error, required } = this.props; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,13 @@ export const styleSheet = createStyleSheet('MuiInput', (theme) => { | |
wrapper: { | ||
// Mimics the default input display property used by browsers for an input. | ||
display: 'inline-block', | ||
marginBottom: 8, | ||
marginTop: 8, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hum, why changing that? The less our component impact the layout, the better. |
||
position: 'relative', | ||
}, | ||
formControl: { | ||
marginTop: 10, | ||
marginBottom: 10, | ||
marginBottom: 0, | ||
marginTop: 16, | ||
}, | ||
inkbar: { | ||
'&:after': { | ||
|
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.
Nothing guarantee the
props.children
to be a flat array.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.
React provides a
Children.map
utility function.