diff --git a/src/components/TextInput/__tests__/index-test.js b/src/components/TextInput/__tests__/index-test.js
index 18fca322..38b9c964 100644
--- a/src/components/TextInput/__tests__/index-test.js
+++ b/src/components/TextInput/__tests__/index-test.js
@@ -237,6 +237,35 @@ describe('components/TextInput', () => {
done();
}
});
+
+ test('multi-line input', () => {
+ const onSubmitEditing = jest.fn();
+ const input = findNativeTextarea(
+ mount()
+ );
+ input.simulate('keyPress', { which: 13 });
+ expect(onSubmitEditing).not.toHaveBeenCalled();
+ });
+
+ test('multi-line input with "blurOnSubmit" triggers onSubmitEditing', () => {
+ const onSubmitEditing = jest.fn();
+ const input = findNativeTextarea(
+ mount(
+
+ )
+ );
+
+ // shift+enter should enter newline, not submit
+ input.simulate('keyPress', { which: 13, shiftKey: true });
+ input.simulate('keyPress', { which: 13 });
+ expect(onSubmitEditing).toHaveBeenCalledTimes(1);
+ expect(onSubmitEditing).not.toHaveBeenCalledWith(expect.objectContaining({ shiftKey: true }));
+ });
});
test('prop "secureTextEntry"', () => {
diff --git a/src/components/TextInput/index.js b/src/components/TextInput/index.js
index 2537fd7f..44beeef2 100644
--- a/src/components/TextInput/index.js
+++ b/src/components/TextInput/index.js
@@ -318,8 +318,8 @@ class TextInput extends Component {
}
}
- if (!e.isDefaultPrevented() && e.which === 13) {
- if (onSubmitEditing) {
+ if (!e.isDefaultPrevented() && e.which === 13 && !e.shiftKey) {
+ if ((blurOnSubmit || !multiline) && onSubmitEditing) {
e.nativeEvent = { target: e.target, text: e.target.value };
onSubmitEditing(e);
}