Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blur TextInput when tapped outside of it

I'm experiencing issue using TextInput expected behaviour is that when I tap on it, it is focused and keyboard is shown, and when I tap around it (anywhere besides the input), the TextInput should blur and keyboard will go away. At present this doesn't happen, text input stays focused no matter where I click. Is this expected behaviour, if so how is it usually handled?

<Image source={require('../assets/background.jpg')} style={{width: undefined; height: undefined; flex: 1;}}>
  <View>
    <TextInput placeholder="Email" style={{ width: 200; height: 40; }} />
  </View>
</Image>
like image 582
Ilja Avatar asked Jan 02 '17 12:01

Ilja


1 Answers

Unfortunately that is expected behaviour.

You should wrap TextInput inside ScrollView (and disable scrolling if needed) and then with property keyboardShouldPersistTaps="never".

like image 57
Samuli Hakoniemi Avatar answered Oct 07 '22 23:10

Samuli Hakoniemi