Skip to content

Commit

Permalink
Fix incorrect touchable hitSlop and pressRetentionOffset type (#36065)
Browse files Browse the repository at this point in the history
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: #36065

Test Plan: None needed

Reviewed By: christophpurrer

Differential Revision: D43117689

Pulled By: javache

fbshipit-source-id: 96e5ae650f47382c8d7fa1ddf63c76461c65dcc7
  • Loading branch information
bigcupcoffee authored and facebook-github-bot committed Feb 9, 2023
1 parent 6d1667c commit 23607ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 23607ae

Please sign in to comment.