Skip to content

Commit bdf3c79

Browse files
yungstersfacebook-github-bot
authored andcommitted
RN: Fix TouchableHighlight w/o onLongPress
Summary: When `TouchableHighlight` was migrated to use `Pressability`, a bug was introduced due to `onLongPress` being unconditionally supplied as a callback. This bug leads to `onPress` not firing if the element is pressed for longer than 500ms, even when `onLongPress` is not supplied. Closes #29040. Changelog: [General][Fixed] - TouchableHighlight fires `onPress` when pressed for >500ms, when `onLongPress` is not supplied. Reviewed By: TheSavior Differential Revision: D23664365 fbshipit-source-id: 3a0e92e276871eedd303888346a13433be15ac47
1 parent 8e9d3ce commit bdf3c79

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

Libraries/Components/Touchable/TouchableBounce.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,7 @@ class TouchableBounce extends React.Component<Props, State> {
7272
this.props.onFocus(event);
7373
}
7474
},
75-
onLongPress: event => {
76-
if (this.props.onLongPress != null) {
77-
this.props.onLongPress(event);
78-
}
79-
},
75+
onLongPress: this.props.onLongPress,
8076
onPress: event => {
8177
const {onPressAnimationComplete, onPressWithCompletion} = this.props;
8278
const releaseBounciness = this.props.releaseBounciness ?? 10;

Libraries/Components/Touchable/TouchableHighlight.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,7 @@ class TouchableHighlight extends React.Component<Props, State> {
193193
this.props.onFocus(event);
194194
}
195195
},
196-
onLongPress: event => {
197-
if (this.props.onLongPress != null) {
198-
this.props.onLongPress(event);
199-
}
200-
},
196+
onLongPress: this.props.onLongPress,
201197
onPress: event => {
202198
if (this._hideTimeout != null) {
203199
clearTimeout(this._hideTimeout);

0 commit comments

Comments
 (0)