Skip to content

TouchBackend: Clear old timeout in handleTopMoveStartDelay#3664

Open
raineorshine wants to merge 2 commits intoreact-dnd:mainfrom
raineorshine:patch-2
Open

TouchBackend: Clear old timeout in handleTopMoveStartDelay#3664
raineorshine wants to merge 2 commits intoreact-dnd:mainfrom
raineorshine:patch-2

Conversation

@raineorshine
Copy link
Contributor

Problem

Normally, delayTouchStart requires that the user tap and hold the draggable element for a given delay before a drag is initiated. If there is a touchmove during this time, the drag is cancelled.

However, if the user quickly touches the screen and then initiates a tap + move within delayTouchStart, the drag will incorrectly start, ignoring the move that would have cancelled it.

A real-world case is described in cybersemics/em#2967.

Cause

This occurs because the handleTopMoveStart timer is only cleared in handleTopMove. When handleTouchStartDelay is triggered in quick session (by two taps), then the second call to handleTouchStartDelay will overwrite the existing timer before handleTopMove has the chance to clear it. Thus, when handleTopMove fires, it only clears the second timer, and the first incorrectly resolves handleTouchStart thinking that the user has not moved their finger.

Solution

This is fixed by clearing the old timer before setting the new timer.

@raineorshine
Copy link
Contributor Author

@darthtrevino Ready for review! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant