Skip to content

Commit

Permalink
[paper][touchhandler] Fix mouse dragging events being flagged as dupl…
Browse files Browse the repository at this point in the history
…icate events

Summary:
Update the duplicate event detection logic to allow mouse drag events to be sent out continuously.

Mouse drag events maintain the same event type and event number, but update the location of the event. This diff checks for location updates so that mouse drag events wouldn't be flagged as duplicates.

Test Plan:
Launch RNTester, click and drag in and out of a Pressable in the Pressable demo.

Without the fix:
https://pxl.cl/2wq4R

With the fix:
https://pxl.cl/2wq4W

Reviewers: shawndempsey, chpurrer

Reviewed By: shawndempsey

Differential Revision: https://phabricator.intern.facebook.com/D43985809

Tasks: T147732113
  • Loading branch information
Nick Lefever authored and shwanton committed May 2, 2024
1 parent 9d08c3e commit b5a5754
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react-native/React/Base/RCTTouchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event

- (BOOL)isDuplicateEvent:(NSEvent *)event
{
if (_lastEvent && (event == _lastEvent || (event.eventNumber == _lastEvent.eventNumber && event.type == _lastEvent.type))) {
if (_lastEvent && (event == _lastEvent || (event.eventNumber == _lastEvent.eventNumber && event.type == _lastEvent.type && NSEqualPoints(event.locationInWindow, _lastEvent.locationInWindow )))) {
return YES;
}

Expand Down

0 comments on commit b5a5754

Please sign in to comment.