TouchableOpacity as Item in ListView only reacts after TextInput has lost focus

前端 未结 1 1082
旧巷少年郎
旧巷少年郎 2020-12-16 15:41

I\'m working on a search component right now which consists of a TextInput and a ListView. It loads its results from an external server and fills the ListView accordingly.

相关标签:
1条回答
  • 2020-12-16 16:17

    The ScrollView (and legacy ListView) component has a prop keyboardShouldPersistTaps which takes three options:

    • 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).

    Example

    <ScrollView keyboardShouldPersistTaps="always">
      // Your TextInput and Button here…
    </ScrollView>
    

    I set this property to true and it works as expected. =)

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