I'm building a React Native app that has a view that contains TextInput
and ListView
.
The way it works is when the TextInput receives focus - the keyboard opens and the user can filter the data in the ListView.
The desired functionality is that in case the user taps/selects on of the rows in the list view the tap should be detected and a method called.
The issue:
When the keyboard is open, tapping the list view closes the keyboard and a second tap will be detected by the row (the tap event is not propagated to the ListView row).
Any idea how the first tap be detected by the onPress method?
Thanks in advance for the help.
You need to add the property keyboardShouldPersistTaps={always}
to your ScrollView.
Here is what the docs say :
keyboardShouldPersistTaps
Determines when the keyboard should stay visible after a tap.
'never'
(the default), tapping outside of the focused text input when the keyboard is up dismisses the keyboard. When this happens, children won't receive the tap.
'always'
, the keyboard will not dismiss automatically, and the scroll view will > not catch taps, but children of the scroll view can catch taps.
'handled'
, the keyboard will not dismiss automatically when the tap was handled by a children, (or captured by an ancestor).
false
, deprecated, use 'never' instead
true
, deprecated, use 'always' instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With