[fix] TextInput props

- Add missing 'onSubmitEditing' propType and test
- Add 'dir=auto' DOM attribute to allow browser to switch writing
  direction for RTL languages
This commit is contained in:
Nicolas Gallagher
2016-12-17 23:38:36 +00:00
parent 7cda89c5ce
commit dc7f526f6b
2 changed files with 12 additions and 2 deletions
@@ -169,8 +169,6 @@ describe('components/TextInput', () => {
}
});
test('prop "onLayout"');
test('prop "onSelectionChange"', (done) => {
const input = findNativeInput(mount(<TextInput defaultValue='12345' onSelectionChange={onSelectionChange} />));
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(<TextInput defaultValue='12345' onSubmitEditing={onSubmitEditing} />));
input.simulate('keyPress', { which: 13 });
function onSubmitEditing(e) {
done();
}
});
});
test('prop "secureTextEntry"', () => {
let input = findNativeInput(shallow(<TextInput secureTextEntry />));
expect(input.prop('type')).toEqual('password');
+2
View File
@@ -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),