Skip to content

Commit 0c392bc

Browse files
yungstersfacebook-github-bot
authored andcommitted
Pressability: Consistently Fire onPress{In,Out} w/o onPress
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
1 parent a6395d5 commit 0c392bc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Libraries/Pressability/Pressability.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -679,18 +679,18 @@ export default class Pressability {
679679
}
680680

681681
if (isPressInSignal(prevState) && signal === 'RESPONDER_RELEASE') {
682+
// If we never activated (due to delays), activate and deactivate now.
683+
if (!isNextActive && !isPrevActive) {
684+
this._activate(event);
685+
this._deactivate(event);
686+
}
682687
const {onLongPress, onPress, android_disableSound} = this._config;
683688
if (onPress != null) {
684689
const isPressCanceledByLongPress =
685690
onLongPress != null &&
686691
prevState === 'RESPONDER_ACTIVE_LONG_PRESS_IN' &&
687692
this._shouldLongPressCancelPress();
688693
if (!isPressCanceledByLongPress) {
689-
// If we never activated (due to delays), activate and deactivate now.
690-
if (!isNextActive && !isPrevActive) {
691-
this._activate(event);
692-
this._deactivate(event);
693-
}
694694
if (Platform.OS === 'android' && android_disableSound !== true) {
695695
SoundManager.playTouchSound();
696696
}

0 commit comments

Comments
 (0)