Skip to content

Commit

Permalink
RN: Persist Asynchronously Consumed Events in Pressability
Browse files Browse the repository at this point in the history
Summary:
There are a few places in `Pressability` where we asynchronously consume the `event` object.

Most places do not encounter any problems because the actual properties on `event` are seldom used.

Nonetheless, we should fix these gaps.

Changelog:
[General][Fixed] - Fix invalid `event` objects from `onPressOut` in certain cases

Reviewed By: rickhanlonii

Differential Revision: D21657126

fbshipit-source-id: e28d825b85d25602427beaf0bd603d22eaa5960a
  • Loading branch information
yungsters authored and facebook-github-bot committed May 20, 2020
1 parent c8d678a commit 2c600b7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Libraries/Pressability/Pressability.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ export default class Pressability {
this._config.delayHoverIn,
);
if (delayHoverIn > 0) {
event.persist();
this._hoverInDelayTimeout = setTimeout(() => {
onHoverIn(event);
}, delayHoverIn);
Expand All @@ -593,6 +594,7 @@ export default class Pressability {
this._config.delayHoverOut,
);
if (delayHoverOut > 0) {
event.persist();
this._hoverInDelayTimeout = setTimeout(() => {
onHoverOut(event);
}, delayHoverOut);
Expand Down Expand Up @@ -729,6 +731,7 @@ export default class Pressability {
normalizeDelay(this._config.delayPressOut),
);
if (delayPressOut > 0) {
event.persist();
this._pressOutDelayTimeout = setTimeout(() => {
onPressOut(event);
}, delayPressOut);
Expand Down

0 comments on commit 2c600b7

Please sign in to comment.