-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onSubmitEditing event is firing twice on android #10443
Comments
Same thing here. I had to implement the following workaround for now: let timeout
...
_onSubmit = () => {
if (timeout) clearTimeout(timeout)
timeout = setTimeout(() => {
//code here
}, 1000)
}; |
Same thing here. |
0.34 also appear twice on android, works perfect on iOS |
The problem is that Android fires two Generally I see two options to fix the issue:
I will dig a little further into the second option, as this one would create a consistent experience, and see if that works, unless, of course, someone has a better idea how to fix it. |
same thing here, and it won't blur when press search button even I have set RN Version: 0.36.0 |
same thing here RN Version 0.39 Android |
same thing here as well RN Version 0.39 Android |
setting blurOnSubmit={false} worked for me on android |
@rangav yea this is true but it doesn't hide the keyboard then. |
@dwilt the only workaround I found was to set Check out https://github.com/DanielMSchmidt/react-native-dismiss-keyboard I used it like this:
|
@ddeanto I don't think I like this as much cause the keyboard would show for a bit, no? I (edited for brevity) import debounce from 'debounce';
// ...
// redefined the onSubmit prop with a debounce
// hack fix for https://github.com/facebook/react-native/issues/10443
onSubmit = Platform.OS === 'android' ? debounce(this.props.onSubmit, 200) : this.props.onSubmit;
// ...
<TextInput
onSubmitEditing={this.onSubmit}
/> |
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
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 facebook#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 facebook#11006 Differential Revision: D4439110 Pulled By: hramos fbshipit-source-id: 5573b7f15f862b432600ddd3d61a0852ce51b2b3
I'm still seeing this issue on RN 0.45.1. what is the accepted solution? |
Issue Description
onSubmitEditing event is firing twice on android.
Steps to Reproduce / Code Snippets
Create the following code:
Then, tap on the field, type something and tap the search button on keyboard.
Expected Results
On iOS it works perfectly (the _onSubmit method is called only one time) but on Android it is calling two times.
Additional Information
The text was updated successfully, but these errors were encountered: