Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where the browser follows a link after a drag. The previous code checked if the element emitting the
mousemove
event is an anchor, but the browser will redirect even if one of its parents is an anchor. Also, the check is moved to themousedown
handler for performance. There's no need to check the DOM for anchor tags on eachmousemove
event. It's unlikely that the result will change since the lastmousedown
.Edit: Also,
preventDefault()
is called only when the item is not dragged beyond the required threshold. It often happens that you accidentally move the mouse 1-2 pixels when clicking. This would prevent the redirection from happening, when the intention was the opposite. Now, the redirection will be avoided only when you've dragged enough, I.E. you actually tried to drag, not click.