React Native TextInput blur consumes TouchableHighlight press event

前端 未结 2 1188
一生所求
一生所求 2020-12-31 02:09

I have a that I\'d like to submit when I tap the red Post button, a . When the TextInput is focused, I

相关标签:
2条回答
  • 2020-12-31 02:34

    @frank, I imagine you found a workable solution, but in addition to the 'keyboardShouldPersistTaps', if you wrap your view in a TouchableWithoutFeedback element with an onPress that calls dismissKeyboard it should fix the issue.

     <ScrollView keyboardShouldPersistTaps={true} ref='scrollView'>
       <TouchableWithoutFeedback onPress={dismissKeyboard}>
         <View>
         -View Content-
         </View>
      </TouchableWithoutFeedback>
    </ScrollView>
    
    0 讨论(0)
  • 2020-12-31 02:41

    You need to add the property keyboardShouldPersistTaps={true} to your ScrollView.

    Here is what the docs say :

    keyboardShouldPersistTaps bool:

    When false, tapping outside of the focused text input when the keyboard is up dismisses the keyboard. When true, the scroll view will not catch taps, and the keyboard will not dismiss automatically. The default value is false.

    0 讨论(0)
提交回复
热议问题