Skip to content

Commit

Permalink
RN: Fix TouchableHighlight w/o onLongPress
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yungsters authored and facebook-github-bot committed Sep 12, 2020
1 parent 8e9d3ce commit bdf3c79
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions Libraries/Components/Touchable/TouchableBounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ class TouchableBounce extends React.Component<Props, State> {
this.props.onFocus(event);
}
},
onLongPress: event => {
if (this.props.onLongPress != null) {
this.props.onLongPress(event);
}
},
onLongPress: this.props.onLongPress,
onPress: event => {
const {onPressAnimationComplete, onPressWithCompletion} = this.props;
const releaseBounciness = this.props.releaseBounciness ?? 10;
Expand Down
6 changes: 1 addition & 5 deletions Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,7 @@ class TouchableHighlight extends React.Component<Props, State> {
this.props.onFocus(event);
}
},
onLongPress: event => {
if (this.props.onLongPress != null) {
this.props.onLongPress(event);
}
},
onLongPress: this.props.onLongPress,
onPress: event => {
if (this._hideTimeout != null) {
clearTimeout(this._hideTimeout);
Expand Down

0 comments on commit bdf3c79

Please sign in to comment.