From dc7f526f6b778ce8e4892eaf211aa09669d2c88d Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Sat, 17 Dec 2016 23:38:36 +0000 Subject: [PATCH] [fix] TextInput props - Add missing 'onSubmitEditing' propType and test - Add 'dir=auto' DOM attribute to allow browser to switch writing direction for RTL languages --- src/components/TextInput/__tests__/index-test.js | 12 ++++++++++-- src/components/TextInput/index.js | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/TextInput/__tests__/index-test.js b/src/components/TextInput/__tests__/index-test.js index eae052cc..3e02acf5 100644 --- a/src/components/TextInput/__tests__/index-test.js +++ b/src/components/TextInput/__tests__/index-test.js @@ -169,8 +169,6 @@ describe('components/TextInput', () => { } }); - test('prop "onLayout"'); - test('prop "onSelectionChange"', (done) => { const input = findNativeInput(mount()); input.simulate('select', { target: { selectionStart: 0, selectionEnd: 3 } }); @@ -181,6 +179,16 @@ describe('components/TextInput', () => { } }); + describe('prop "onSubmitEditing"', () => { + test('single-line input', (done) => { + const input = findNativeInput(mount()); + input.simulate('keyPress', { which: 13 }); + function onSubmitEditing(e) { + done(); + } + }); + }); + test('prop "secureTextEntry"', () => { let input = findNativeInput(shallow()); expect(input.prop('type')).toEqual('password'); diff --git a/src/components/TextInput/index.js b/src/components/TextInput/index.js index 923e4b1c..4f0adcb7 100644 --- a/src/components/TextInput/index.js +++ b/src/components/TextInput/index.js @@ -72,6 +72,7 @@ class TextInput extends Component { onFocus: PropTypes.func, onKeyPress: PropTypes.func, onSelectionChange: PropTypes.func, + onSubmitEditing: PropTypes.func, placeholder: PropTypes.string, placeholderTextColor: PropTypes.string, secureTextEntry: PropTypes.bool, @@ -188,6 +189,7 @@ class TextInput extends Component { const props = { ...other, autoCorrect: autoCorrect ? 'on' : 'off', + dir: 'auto', onBlur: normalizeEventHandler(this._handleBlur), onChange: normalizeEventHandler(this._handleChange), onFocus: normalizeEventHandler(this._handleFocus),