Skip to content

Commit

Permalink
Pressability: Consistently Fire onPress{In,Out} w/o onPress
Browse files Browse the repository at this point in the history
Summary:
Currently any component using `Pressability` is quickly tapped and released (i.e. responder grant followed only by reponder release), we fire `onPressIn` and `onPressOut` immediately to ensure that any visual feedback for the interactive element is momentarily visible.

Currently, we were mistakenly skipping this logic if `onPress` was null.

This fixes it so that we fire `onPressIn` and `onPressOut` consistently, even if `onPress` is null.

Changelog:
[General][Fixed] - Pressability now consistently fires `onPressIn` and `onPressOut`, even without an `onPress`.

Reviewed By: lunaleaps

Differential Revision: D23613254

fbshipit-source-id: e316707cbb2a4814262dea4eb1ddf6e3780268d1
  • Loading branch information
yungsters authored and facebook-github-bot committed Sep 11, 2020
1 parent a6395d5 commit 0c392bc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Libraries/Pressability/Pressability.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,18 +679,18 @@ export default class Pressability {
}

if (isPressInSignal(prevState) && signal === 'RESPONDER_RELEASE') {
// If we never activated (due to delays), activate and deactivate now.
if (!isNextActive && !isPrevActive) {
this._activate(event);
this._deactivate(event);
}
const {onLongPress, onPress, android_disableSound} = this._config;
if (onPress != null) {
const isPressCanceledByLongPress =
onLongPress != null &&
prevState === 'RESPONDER_ACTIVE_LONG_PRESS_IN' &&
this._shouldLongPressCancelPress();
if (!isPressCanceledByLongPress) {
// If we never activated (due to delays), activate and deactivate now.
if (!isNextActive && !isPrevActive) {
this._activate(event);
this._deactivate(event);
}
if (Platform.OS === 'android' && android_disableSound !== true) {
SoundManager.playTouchSound();
}
Expand Down

0 comments on commit 0c392bc

Please sign in to comment.