rgommezz / react-native-scroll-bottom-sheet

Cross platform scrollable bottom sheet with virtualisation support, native animations at 60 FPS and fully implemented in JS land :fire:
MIT License
1.54k stars 64 forks source link

On item: Pressable not detected. TouchableHightligth is detected #73

Open asalha opened 3 years ago

asalha commented 3 years ago

Current Behavior

Very weird behavior. If I use Pressable, the click is detected once over 100 of the times. With TouchableHighlight, it works perfectly!

How to reproduce

When I replace in the code below TouchableHighligth with Pressable, it doesn't work

<ScrollBottomSheet
        style={{ backgroundColor: "#f8f8f8" }}
        ref={bottomSheetRef}
        componentType="FlatList"
        // snapPoints={[128, "50%", windowHeight]}
        snapPoints={[100, windowHeight]}
        initialSnapIndex={1}
        onSettle={(index) => {
          console.log(index);
        }}
        renderHandle={() => (
          <View style={scrollBottomSheet.header}>
            <View style={scrollBottomSheet.panelHandle} />
          </View>
        )}
        data={groupContext.state.userGroupList}
        keyExtractor={(item) => item.id}
        renderItem={({ item }) => {
          return (
            <TouchableHighlight
              onPress={() => {
                console.log("onPress detected on item");
              }}
              onLongPress={() => {
                console.log("longPress detected on item");
              }}
            >
              <Text>{item.id}</Text>
            </TouchableHighlight>
          );
        }}
        contentContainerStyle={scrollBottomSheet.contentContainerStyle}
      />

Your Environment

version
Platform (Android, iOS or both)
react-native-scroll-bottom-sheet
react-native
react-native-gesture-handler
react-native-reanimated
darkbasic commented 3 years ago

TouchableHighlight works ONLY if you import it from react-native-gesture-handler, not react-native!

darkbasic commented 3 years ago

TouchableHighlight works ONLY if you import it from react-native-gesture-handler, not react-native!

This fix works only in Android, but not on iOS.

The following one works for both: https://gorhom.github.io/react-native-bottom-sheet/troubleshooting/#pressables--touchables-are-not-working-on-android

Please close this issue.