[fix] TextInput calls onSelectionChange upon user input

Fix #1018
This commit is contained in:
Nicolas Gallagher
2018-07-06 15:00:50 -07:00
parent afd5293172
commit 405a3b79e8
2 changed files with 21 additions and 11 deletions

View File

@@ -330,7 +330,8 @@ describe('components/TextInput', () => {
});
});
test('prop "onSelectionChange"', done => {
describe('prop "onSelectionChange"', () => {
test('is called on select', done => {
const input = findNativeInput(
mount(<TextInput defaultValue="12345" onSelectionChange={onSelectionChange} />)
);
@@ -344,6 +345,14 @@ describe('components/TextInput', () => {
}
});
test('is called on change', () => {
const onSelectionChange = jest.fn();
const input = findNativeInput(mount(<TextInput onSelectionChange={onSelectionChange} />));
input.simulate('change');
expect(onSelectionChange).toHaveBeenCalledTimes(1);
});
});
describe('prop "onSubmitEditing"', () => {
test('single-line input', done => {
const input = findNativeInput(

View File

@@ -282,6 +282,7 @@ class TextInput extends Component<*> {
if (onChangeText) {
onChangeText(text);
}
this._handleSelectionChange(e);
};
_handleFocus = e => {