Skip to content

Conversation

@m-bert
Copy link
Contributor

@m-bert m-bert commented Dec 1, 2025

Description

This PR aims to fix callback differences between iOS 26 and 18. Most of them were already resolved, but there were some issues with Pan and onFinalize callback.

Calling reset has been removed from Tap as it is called automatically by recognizer and leaving it resulted in double callbacks.

Note

For related changes, see #3740, #3756 and #3849.

Test plan

Tested on the following code:
import { StyleSheet, View, Text } from 'react-native';

import {
  GestureHandlerRootView,
  Gesture,
  GestureDetector,
  GestureType,
} from 'react-native-gesture-handler';

function TestBox({
  gestureType,
  bgColor,
}: {
  gestureType: GestureType;
  bgColor: string;
}) {
  const handlerName = gestureType.handlerName;

  const gesture = gestureType
    .onBegin(() => {
      console.log(`[${handlerName}] onBegin`);
    })
    .onEnd((_e, s) => {
      console.log(`[${handlerName}] onEnd (${s})`);
    })
    .onFinalize((_e, s) => {
      console.log(`[${handlerName}] onFinalize (${s})`);
    })
    .runOnJS(true);

  try {
    // @ts-ignore this is exactly why we have the try-catch block
    gesture.onUpdate(() => {
      console.log(`[${handlerName}] onUpdate`);
    });
  } catch {
    /* empty */
  }

  return (
    <View style={styles.center}>
      <Text>{handlerName}</Text>
      <GestureDetector gesture={gesture}>
        <View style={[styles.box, { backgroundColor: bgColor }]} />
      </GestureDetector>
    </View>
  );
}

export default function App() {
  return (
    <GestureHandlerRootView style={[{ flex: 1, padding: 50 }, styles.center]}>
      <TestBox gestureType={Gesture.Pan()} bgColor="#b58df1" />
      <TestBox gestureType={Gesture.LongPress()} bgColor="#f1a85d" />
      <TestBox gestureType={Gesture.Fling()} bgColor="#5df1a8" />
      <TestBox gestureType={Gesture.Tap()} bgColor="#5d8ef1" />
    </GestureHandlerRootView>
  );
}

const styles = StyleSheet.create({
  center: {
    display: 'flex',
    justifyContent: 'space-around',
    alignItems: 'center',
  },
  box: {
    height: 100,
    width: 100,
    backgroundColor: '#b58df1',
    borderRadius: 20,
    marginBottom: 30,
  },
});

@m-bert m-bert marked this pull request as ready for review December 2, 2025 11:31
@m-bert m-bert requested review from Copilot and j-piasecki December 2, 2025 11:31
@m-bert m-bert requested review from akwasniewski and removed request for Copilot December 2, 2025 11:32
Copy link
Member

@j-piasecki j-piasecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do these changes impact macOS?

}

- (void)handleGesture:(UIGestureRecognizer *)recognizer
- (void)handleGesture:(UIGestureRecognizer *)recognizer fromReset:(BOOL)fromReset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed in afa3ffa.

@m-bert
Copy link
Contributor Author

m-bert commented Dec 2, 2025

How do these changes impact macOS?

It shouldn't break anything, I've compiled example app and checked some of the examples, along with provided test code.

@m-bert m-bert merged commit 14b690e into main Dec 4, 2025
4 checks passed
@m-bert m-bert deleted the @mbert/gestures-26 branch December 4, 2025 10:10
m-bert added a commit that referenced this pull request Dec 16, 2025
This PR aims to fix callback differences between `iOS` 26 and 18. Most of them were already resolved, but there were some issues with `Pan` and `onFinalize` callback.

Calling `reset` has been removed from `Tap` as it is called automatically by recognizer and leaving it resulted in double callbacks.

> [!NOTE]
> For related changes, see #3740, #3756 and #3849.

<details>
<summary>Tested on the following code:</summary>

```tsx
import { StyleSheet, View, Text } from 'react-native';

import {
  GestureHandlerRootView,
  Gesture,
  GestureDetector,
  GestureType,
} from 'react-native-gesture-handler';

function TestBox({
  gestureType,
  bgColor,
}: {
  gestureType: GestureType;
  bgColor: string;
}) {
  const handlerName = gestureType.handlerName;

  const gesture = gestureType
    .onBegin(() => {
      console.log(`[${handlerName}] onBegin`);
    })
    .onEnd((_e, s) => {
      console.log(`[${handlerName}] onEnd (${s})`);
    })
    .onFinalize((_e, s) => {
      console.log(`[${handlerName}] onFinalize (${s})`);
    })
    .runOnJS(true);

  try {
    // @ts-ignore this is exactly why we have the try-catch block
    gesture.onUpdate(() => {
      console.log(`[${handlerName}] onUpdate`);
    });
  } catch {
    /* empty */
  }

  return (
    <View style={styles.center}>
      <Text>{handlerName}</Text>
      <GestureDetector gesture={gesture}>
        <View style={[styles.box, { backgroundColor: bgColor }]} />
      </GestureDetector>
    </View>
  );
}

export default function App() {
  return (
    <GestureHandlerRootView style={[{ flex: 1, padding: 50 }, styles.center]}>
      <TestBox gestureType={Gesture.Pan()} bgColor="#b58df1" />
      <TestBox gestureType={Gesture.LongPress()} bgColor="#f1a85d" />
      <TestBox gestureType={Gesture.Fling()} bgColor="#5df1a8" />
      <TestBox gestureType={Gesture.Tap()} bgColor="#5d8ef1" />
    </GestureHandlerRootView>
  );
}

const styles = StyleSheet.create({
  center: {
    display: 'flex',
    justifyContent: 'space-around',
    alignItems: 'center',
  },
  box: {
    height: 100,
    width: 100,
    backgroundColor: '#b58df1',
    borderRadius: 20,
    marginBottom: 30,
  },
});
```

</details>
m-bert added a commit that referenced this pull request Dec 19, 2025
## Description

In #3855 we've introduced `fromReset` argument for `handleGesture`.
However, `ManualActivationRecognizer` does not have such signature. This
PR removes it from selector as `fromReset` is not passed anyway.

## Test plan

Check that on `Pressable` example app no longer crashes when clicking on
**press retention** area.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants