6

This is question regarding Native Base framework for React Native applications:

Imagine a subscribe screen; 1 text input and a subscribe button;

After I type my email address I want to tap on subscribe button but my first tap only closes the keyboard and I need to tap again to press on button. How this can be avoided? My expected behaviour is that first tap is a press on button. (As far as I see this is something around < Content> component but I am not sure.)

(I have checked this issue on native-base kitchen sink app and same issue occurs there as well. Just go to: 'Forms and Input' section and see 'Fixed Label' )

milkersarac
3,4793 gold badges34 silver badges34 bronze badges
asked Jun 22, 2017 at 13:37
4
  • You might want to check this. The problem is not the same as yours but it might give some idea. Commented Jun 22, 2017 at 14:31
  • And also what about using NativeBase's Input and InputGroup components instead of RN's TextInput? Commented Jun 22, 2017 at 14:33
  • @milkersarac thanks for the comments but I use some custom text inputs and that's why, but the answer I accepted solves the problem. Commented Jun 22, 2017 at 23:41
  • Glad it did, great! Commented Jun 23, 2017 at 6:48

3 Answers 3

7

Pass this as a prop to the content component.

< Content keyboardShouldPersistTaps='always'>
answered Jun 22, 2017 at 14:32
Sign up to request clarification or add additional context in comments.

2 Comments

Brilliant, this works (although I haven't gone through implications yet) thanks a lot! I googled for this quite a lot!
in my case i needed to add it on the flatlist component
3

If you use < Content keyboardShouldPersistTaps='always'>, the keypad would not disappear after selecting a button or if you tap outside the input field. To ensure that the keyboard disappears if you tap outside the input field, use

< Content keyboardShouldPersistTaps='handled'>

However, with this, the keyboard would not disappear if you select a button (as opposed to a blank part of the screen) even though the button's onPress event will get fired. To make the keyboard disappear after pressing a button, the onPress handler of the button should call

Keyboard.dismiss()

Don't forget to include the import statement:

import { Keyboard } from 'react-native';

For further details, see https://facebook.github.io/react-native/docs/scrollview.html#keyboardshouldpersisttaps

answered Sep 7, 2017 at 22:43

Comments

2

keyboardShouldPersistTaps this property is now exist in ScrollView.

<ScrollView keyboardShouldPersistTaps="always">
 {..content or component}
</ScrollView>

For more detail Please visit on official document

https://facebook.github.io/react-native/docs/scrollview#keyboardshouldpersisttaps

answered Jan 29, 2019 at 11:49

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.