react-native-keyboard-aware-scroll-view
react-native-keyboard-aware-scroll-view copied to clipboard
Tap to dismiss keyboard
I have a KeyboardAwareScrollView
surrounding some text inputs. When I click away from a text input, I'm hoping to dismiss the keyboard so I set keyboardShouldPersistTaps={'handled'}
but it doesn't seem to dismiss the keyboard
Use TouchableWithoutFeedback
to wrap around your KeyboardAwareScrollView
and onPress of TouchableWithoutFeedback
add onPress={Keyboard.dismiss} and accessbile={false}
Note: Keyboard, TouchableWithoutFeedback needs to be imported from react-native.
Example:
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<KeyboardAwareScrollView>
{your code}
</KeyboardAwareScrollView>
</TouchableWithoutFeedback>
@sikandarchishty That works but I feel like that dismissing the keyboard when tapping away should be the default behaviour