From 6e4d23ded2da4a717bafcc032e3d7a0a5fbe3731 Mon Sep 17 00:00:00 2001 From: Zeya Peng Date: Mon, 28 Jul 2025 08:34:04 -0700 Subject: [PATCH] Allow setting blockNativeResponder on Pressable (#52819) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52819 ## Changelog: [General] [Added] - Allow setting blockNativeResponder on Pressable To expose the same prop on Pressability https://github.com/facebook/react-native/blob/b2d9f5f28045fd89bba2dca41274c7cd7abe2ecc/packages/react-native/Libraries/Pressability/Pressability.js#L137 Reviewed By: christophpurrer Differential Revision: D78896178 fbshipit-source-id: 36637842ac15c54de325975d416efce1448e8ab7 --- .../Libraries/Components/Pressable/Pressable.js | 9 +++++++++ packages/react-native/ReactNativeApi.d.ts | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/react-native/Libraries/Components/Pressable/Pressable.js b/packages/react-native/Libraries/Components/Pressable/Pressable.js index f994e0e929f..42d94a758aa 100644 --- a/packages/react-native/Libraries/Components/Pressable/Pressable.js +++ b/packages/react-native/Libraries/Components/Pressable/Pressable.js @@ -116,6 +116,12 @@ type PressableBaseProps = $ReadOnly<{ */ onPressOut?: ?(event: GestureResponderEvent) => mixed, + /** + * Whether to prevent any other native components from becoming responder + * while this pressable is responder. + */ + blockNativeResponder?: ?boolean, + /** * Either view styles or a function that receives a boolean reflecting whether * the component is currently pressed and returns view styles. @@ -183,6 +189,7 @@ function Pressable({ 'aria-expanded': ariaExpanded, 'aria-label': ariaLabel, 'aria-selected': ariaSelected, + blockNativeResponder, cancelable, children, delayHoverIn, @@ -294,10 +301,12 @@ function Pressable({ onPressOut(event); } }, + blockNativeResponder, }), [ android_disableSound, android_rippleConfig, + blockNativeResponder, cancelable, delayHoverIn, delayHoverOut, diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index e2da412d8fa..d21b62c9d14 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<56f048751e6094736be604305b9c6f02>> + * @generated SignedSource<<1f77cd57f1bd57ae59c61a1cc6a58d81>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -3759,6 +3759,7 @@ declare type PressableAndroidRippleConfig = { declare type PressableBaseProps = { readonly android_disableSound?: boolean readonly android_ripple?: PressableAndroidRippleConfig + readonly blockNativeResponder?: boolean readonly cancelable?: boolean readonly children?: | ((state: PressableStateCallbackType) => React.ReactNode) @@ -6078,7 +6079,7 @@ export { PointerEvent, // 3c454015 Pressable, // 3c6e4eb9 PressableAndroidRippleConfig, // 42bc9727 - PressableProps, // 4d37b376 + PressableProps, // 00d5ea16 PressableStateCallbackType, // 9af36561 ProcessedColorValue, // 33f74304 ProgressBarAndroid, // 03e66cf5