mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-24 07:09:03 +00:00
[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:
@@ -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');
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user