mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-30 09:19:21 +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) => {
|
test('prop "onSelectionChange"', (done) => {
|
||||||
const input = findNativeInput(mount(<TextInput defaultValue='12345' onSelectionChange={onSelectionChange} />));
|
const input = findNativeInput(mount(<TextInput defaultValue='12345' onSelectionChange={onSelectionChange} />));
|
||||||
input.simulate('select', { target: { selectionStart: 0, selectionEnd: 3 } });
|
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"', () => {
|
test('prop "secureTextEntry"', () => {
|
||||||
let input = findNativeInput(shallow(<TextInput secureTextEntry />));
|
let input = findNativeInput(shallow(<TextInput secureTextEntry />));
|
||||||
expect(input.prop('type')).toEqual('password');
|
expect(input.prop('type')).toEqual('password');
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class TextInput extends Component {
|
|||||||
onFocus: PropTypes.func,
|
onFocus: PropTypes.func,
|
||||||
onKeyPress: PropTypes.func,
|
onKeyPress: PropTypes.func,
|
||||||
onSelectionChange: PropTypes.func,
|
onSelectionChange: PropTypes.func,
|
||||||
|
onSubmitEditing: PropTypes.func,
|
||||||
placeholder: PropTypes.string,
|
placeholder: PropTypes.string,
|
||||||
placeholderTextColor: PropTypes.string,
|
placeholderTextColor: PropTypes.string,
|
||||||
secureTextEntry: PropTypes.bool,
|
secureTextEntry: PropTypes.bool,
|
||||||
@@ -188,6 +189,7 @@ class TextInput extends Component {
|
|||||||
const props = {
|
const props = {
|
||||||
...other,
|
...other,
|
||||||
autoCorrect: autoCorrect ? 'on' : 'off',
|
autoCorrect: autoCorrect ? 'on' : 'off',
|
||||||
|
dir: 'auto',
|
||||||
onBlur: normalizeEventHandler(this._handleBlur),
|
onBlur: normalizeEventHandler(this._handleBlur),
|
||||||
onChange: normalizeEventHandler(this._handleChange),
|
onChange: normalizeEventHandler(this._handleChange),
|
||||||
onFocus: normalizeEventHandler(this._handleFocus),
|
onFocus: normalizeEventHandler(this._handleFocus),
|
||||||
|
|||||||
Reference in New Issue
Block a user