Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with element inside anchor #248

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix bug with element inside anchor #248

wants to merge 2 commits into from

Conversation

hdodov
Copy link

@hdodov hdodov commented May 15, 2019

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 the mousedown handler for performance. There's no need to check the DOM for anchor tags on each mousemove event. It's unlikely that the result will change since the last mousedown.

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.

brabli added a commit to brabli/siema that referenced this pull request Nov 7, 2021
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.

None yet

1 participant