mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
TextInput: Avoid firing onSubmitEditing twice on Android
Summary: For returnKeyType 'go', 'search' and 'send' Android will call onEditorAction twice, once with IME_NULL and another time with the respective IME_ACTION. This change makes sure to only fire one onSubmitEditing by always returning true in onEditorAction, which causes no subsequent events to be fired by android. Fixes #10443 **Test plan** 1. Create view with TextInput having 'go', 'search' or 'send as `returnKeyType` ```javascript <View> <TextInput returnKeyType='search' onSubmitEditing={event => console.log('submit search')}></TextInput> <TextInput returnKeyType='go' onSubmitEditing={event => console.log('submit go')}></TextInput> <TextInput returnKeyType='send' onSubmitEditing={event => console.log('submit send')}></TextInput> </View> ``` 2. Input some text and click submit button in soft keyboard 3. See event fired only once instead of two times Closes https://github.com/facebook/react-native/pull/11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
This commit is contained in:
committed by
Facebook Github Bot
parent
f521e992cc
commit
116916b98d
+5
-7
@@ -688,14 +688,12 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
editText.getId(),
|
||||
editText.getText().toString()));
|
||||
}
|
||||
if (actionId == EditorInfo.IME_ACTION_NEXT ||
|
||||
actionId == EditorInfo.IME_ACTION_PREVIOUS) {
|
||||
if (editText.getBlurOnSubmit()) {
|
||||
editText.clearFocus();
|
||||
}
|
||||
return true;
|
||||
|
||||
if (editText.getBlurOnSubmit()) {
|
||||
editText.clearFocus();
|
||||
}
|
||||
return !editText.getBlurOnSubmit();
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user