[fix] TextInput styles

Ref #166
This commit is contained in:
Nicolas Gallagher
2016-07-12 17:46:56 -07:00
parent f4515a3995
commit 30bf00a3bc
3 changed files with 28 additions and 10 deletions
@@ -223,6 +223,19 @@ suite('components/TextInput', () => {
// assert.equal(input.node.selectionStart, 0)
})
test('prop "style"', () => {
const styles = StyleSheet.create({
root: {
borderWidth: 1,
textAlign: 'center'
}
})
const textInput = shallow(<TextInput style={styles.root} />)
const input = findNativeInput(textInput)
assert.equal(StyleSheet.flatten(textInput.prop('style')).borderWidth, 1, 'expected View styles to be applied to the "View"')
assert.equal(input.prop('style').textAlign, 'center', 'expected Text styles to be applied to the "input"')
})
test('prop "value"', () => {
const value = 'value'
const input = findNativeInput(shallow(<TextInput value={value} />))
+4 -4
View File
@@ -121,8 +121,9 @@ class TextInput extends Component {
// In order to support 'Text' styles on 'TextInput', we split the 'Text'
// and 'View' styles and apply them to the 'Text' and 'View' components
// used in the implementation
const rootStyles = pick(style, viewStyleProps)
const textStyles = omit(style, viewStyleProps)
const flattenedStyle = StyleSheet.flatten(style)
const rootStyles = pick(flattenedStyle, viewStyleProps)
const textStyles = omit(flattenedStyle, viewStyleProps)
const propsCommon = {
autoComplete: autoComplete && 'on',
@@ -236,8 +237,7 @@ applyNativeMethods(TextInput)
const styles = StyleSheet.create({
initial: {
borderColor: 'black',
borderWidth: 1
borderColor: 'black'
},
wrapper: {
flex: 1