From 23607aea688c950fe0cf424b280a2339636130fe Mon Sep 17 00:00:00 2001 From: bigcupcoffee <24373206+bigcupcoffee@users.noreply.github.com> Date: Thu, 9 Feb 2023 03:05:23 -0800 Subject: [PATCH] Fix incorrect touchable hitSlop and pressRetentionOffset type (#36065) Summary: Incorrect TS type disallows use of `hitSlop={number}`. Fixed by using Pressable's hitSlop type. NOTE: I did not bother to change Flow types in the `.js` file, please add a commit doing that if required. ## Changelog [GENERAL] [FIXED] - Fix touchable hitSlop type Pull Request resolved: https://github.com/facebook/react-native/pull/36065 Test Plan: None needed Reviewed By: christophpurrer Differential Revision: D43117689 Pulled By: javache fbshipit-source-id: 96e5ae650f47382c8d7fa1ddf63c76461c65dcc7 --- .../Components/Touchable/TouchableWithoutFeedback.d.ts | 4 ++-- Libraries/Components/Touchable/TouchableWithoutFeedback.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts b/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts index a6f3316d36be14..aa5e14b7e2705d 100644 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts @@ -69,7 +69,7 @@ export interface TouchableWithoutFeedbackProps * the Z-index of sibling views always takes precedence if a touch hits * two overlapping views. */ - hitSlop?: Insets | undefined; + hitSlop?: null | Insets | number | undefined; /** * Used to reference react managed views from native code. @@ -121,7 +121,7 @@ export interface TouchableWithoutFeedbackProps * while the scroll view is disabled. Ensure you pass in a constant * to reduce memory allocations. */ - pressRetentionOffset?: Insets | undefined; + pressRetentionOffset?: null | Insets | number | undefined; /** * Used to locate this view in end-to-end tests. diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index 3963273175a4fd..7c029ed9a0fcfe 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -15,7 +15,7 @@ import type { AccessibilityState, AccessibilityValue, } from '../../Components/View/ViewAccessibility'; -import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; +import type {EdgeInsetsOrSizeProp} from '../../StyleSheet/EdgeInsetsPropType'; import type { BlurEvent, FocusEvent, @@ -67,7 +67,7 @@ type Props = $ReadOnly<{| delayPressOut?: ?number, disabled?: ?boolean, focusable?: ?boolean, - hitSlop?: ?EdgeInsetsProp, + hitSlop?: ?EdgeInsetsOrSizeProp, id?: string, importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), nativeID?: ?string, @@ -79,7 +79,7 @@ type Props = $ReadOnly<{| onPress?: ?(event: PressEvent) => mixed, onPressIn?: ?(event: PressEvent) => mixed, onPressOut?: ?(event: PressEvent) => mixed, - pressRetentionOffset?: ?EdgeInsetsProp, + pressRetentionOffset?: ?EdgeInsetsOrSizeProp, rejectResponderTermination?: ?boolean, testID?: ?string, touchSoundDisabled?: ?boolean,