react-native-gesture-handler icon indicating copy to clipboard operation
react-native-gesture-handler copied to clipboard

[iOS] RectButton does not trigger onPress when nested inside ReanimatedSwippeable

Open focux opened this issue 1 year ago • 8 comments

Description

When RectButton is nested inside ReanimatedSwippeable, it does not trigger the onPress callback unless you long press.

https://github.com/user-attachments/assets/8d720d7e-ad5f-4e15-968a-feccb24ec5fc

Steps to reproduce

  1. Put a RectButton inside a ReanimatedSwipeable and try to trigger the onPress callback.

Snack or a link to a repository

https://github.com/focux/expo-rect-swipeable-bug

Gesture Handler version

2.21.0

React Native version

0.74.5

Platforms

iOS

JavaScript runtime

Hermes

Workflow

Expo bare workflow

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

focux avatar Nov 15 '24 20:11 focux

same here :/ any solution?

LekZ974 avatar Dec 09 '24 13:12 LekZ974

Also seeing this using "react-native-gesture-handler": "^2.21.2"

dpyeates avatar Dec 10 '24 16:12 dpyeates

Hey, could you please confirm this issue still occurs on the latest Gesture Handler release (2.22.0-rc.0)? I recall i reproed this issue successfully in the past, but I can't get the issue to occur anymore. I tested it on the following repro:

Collapsed code
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { RectButton } from 'react-native-gesture-handler';

import Swipeable from 'react-native-gesture-handler/ReanimatedSwipeable';

export default function EmptyExample() {
  return (
    <View style={styles.container}>
      <Swipeable containerStyle={styles.swipeable}>
        <RectButton
          style={styles.button}
          onPress={() => console.log('Pressed: RectButton inside Swipeable')}
          rippleColor={'tomato'}>
          <Text>RectButton inside Swipeable</Text>
        </RectButton>
      </Swipeable>
      <View style={styles.swipeable}>
        <RectButton
          style={styles.button}
          onPress={() => console.log('Pressed: RectButton inside View')}
          rippleColor={'tomato'}>
          <Text>RectButton inside View</Text>
        </RectButton>
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
    gap: 20,
  },
  button: {
    width: 210,
    height: 50,
    backgroundColor: 'pink',
    alignItems: 'center',
    justifyContent: 'center',
  },
  swipeable: {
    width: 400,
    height: 60,
    backgroundColor: 'orange',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

And onPress was working as expected.

Also, the repro you provided 404s, it's either private or unavailable anymore. If this issue persists, could you please send the minimal reproduction here, or set your repo to public?

latekvo avatar Dec 11 '24 11:12 latekvo

Hi there, stumbled upon this as well and can provide more context:

  • Behaviour is still present in the current version
  • Bug can be seen also in the example: https://github.com/software-mansion/react-native-gesture-handler/blob/main/example/src/new_api/swipeable/index.tsx
  • All Touchables and RectButton lead to this bug. Using Pressable fixes the issue
  • Visually the onPress is triggered, but the handler is not invoked.
  • Pressing longer is invoking the handler

I attached a screen recording

https://github.com/user-attachments/assets/48a3f9c5-4ddb-465c-9d8b-60a001d7571b

mkuczera avatar Feb 03 '25 14:02 mkuczera

As a workaround, you can use the old swipeable component that doesn't have this problem.

import Swipeable from 'react-native-gesture-handler/ReanimatedSwipeable';

// replace by

import {Swipeable} from 'react-native-gesture-handler';

PierreCapo avatar May 26 '25 14:05 PierreCapo

Having same issue, any fixes or workaround?

mdevdkumar avatar Jun 17 '25 22:06 mdevdkumar

Apologies for the bump, but we're experiencing this issue as well on Android.

I can confirm the import {Swipeable} from 'react-native-gesture-handler' workaround works.

zpv avatar Jul 15 '25 23:07 zpv

+1

manosKas avatar Oct 08 '25 21:10 manosKas