I'm using this component for some forms in my app but running into an issue with it blocking onPress events from buttons. I'm guessing it's related to the behaviour that dismisses the keyboard when touching outside of a TextInput.
Is there any way to allow those touch events while keeping the keyboard dismissing behaviour?
Keep in mind that this component only adds functionality to ScrollView and its siblings, so this must be an upstream issue with the touch responder system where it can't discern which element should get the touch event.
We've never experienced this issue in any of our apps, can you post source code, platform and versions in order to try to reproduce it?
@alvaromb Yeah you're right, sorry for assuming it was an issue with this library
For anyone else:
I fixed the issue by adding keyboardShouldPersistTaps="handled" to the KeyboardAwareScrollView (or an ordinary ScrollView if that's what you're using...). That lets tap events trickle down to child components (like a button) but still dismisses the keyboard if the touch wasn't handled by any component.
I then added Keyboard.dismiss() to my button touch event handler to stop any funny issues if the keyboard reappeared.
onSubmit() {
Keyboard.dismiss();
...
}
render() {
<KeyboardAwareScrollView
keyboardShouldPersistTaps="handled"
...
>
<Button onPress={() => this.onSubmit()} />
</KeyboardAwareScrollView>
}
Hello, I have the same issue. Your solution only work on ios for me. RN 0.53.
Thanks!
Most helpful comment
@alvaromb Yeah you're right, sorry for assuming it was an issue with this library
For anyone else:
I fixed the issue by adding
keyboardShouldPersistTaps="handled"to theKeyboardAwareScrollView(or an ordinaryScrollViewif that's what you're using...). That lets tap events trickle down to child components (like a button) but still dismisses the keyboard if the touch wasn't handled by any component.I then added
Keyboard.dismiss()to my button touch event handler to stop any funny issues if the keyboard reappeared.