From 6df938c72eb9b71ad626462127164fbb6cd4947c Mon Sep 17 00:00:00 2001 From: Regina Tuk Date: Wed, 19 Mar 2025 16:53:20 -0700 Subject: [PATCH] adding onPressMove to Pressable (#50139) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50139 adding this event to Pressable because it is going to be consumed after to track if pressable location is moved Changelog: [General] [Added] - Expose `onPressMove` as base prop for `Pressable` Reviewed By: thurn Differential Revision: D71429258 fbshipit-source-id: 79acaa735764a47a21d89042d3e4b9c114c72950 --- .../Libraries/Components/Pressable/Pressable.js | 13 ++++++++++++- .../__tests__/__snapshots__/public-api-test.js.snap | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Components/Pressable/Pressable.js b/packages/react-native/Libraries/Components/Pressable/Pressable.js index 0a6cfcd418e..8690fafc828 100644 --- a/packages/react-native/Libraries/Components/Pressable/Pressable.js +++ b/packages/react-native/Libraries/Components/Pressable/Pressable.js @@ -105,6 +105,10 @@ type PressableBaseProps = $ReadOnly<{ * Called when a touch is engaged before `onPress`. */ onPressIn?: ?(event: GestureResponderEvent) => mixed, + /** + * Called when the press location moves. + */ + onPressMove?: ?(event: GestureResponderEvent) => mixed, /** * Called when a touch is released before `onPress`. @@ -185,6 +189,7 @@ function Pressable( onLongPress, onPress, onPressIn, + onPressMove, onPressOut, pressRetentionOffset, style, @@ -263,7 +268,12 @@ function Pressable( onPressIn(event); } }, - onPressMove: android_rippleConfig?.onPressMove, + onPressMove(event: GestureResponderEvent): void { + android_rippleConfig?.onPressMove(event); + if (onPressMove != null) { + onPressMove(event); + } + }, onPressOut(event: GestureResponderEvent): void { if (android_rippleConfig != null) { android_rippleConfig.onPressOut(event); @@ -288,6 +298,7 @@ function Pressable( onLongPress, onPress, onPressIn, + onPressMove, onPressOut, pressRetentionOffset, setPressed, diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index e62ff521468..34aa1902bbb 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -1719,6 +1719,7 @@ type PressableBaseProps = $ReadOnly<{ onLongPress?: ?(event: GestureResponderEvent) => mixed, onPress?: ?(event: GestureResponderEvent) => mixed, onPressIn?: ?(event: GestureResponderEvent) => mixed, + onPressMove?: ?(event: GestureResponderEvent) => mixed, onPressOut?: ?(event: GestureResponderEvent) => mixed, style?: | ViewStyleProp