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

Marker with a element does not open the url when clicked #6730

Closed
exotfboy opened this issue May 24, 2018 · 15 comments
Closed

Marker with a element does not open the url when clicked #6730

exotfboy opened this issue May 24, 2018 · 15 comments

Comments

@exotfboy
Copy link

exotfboy commented May 24, 2018

version: 0.45.0

When add marker(a element) to map, and click the marker. A new page with the href of the marker element should be opened, but nothing happened.

https://jsfiddle.net/8z8vukk0/

Try to click the red marker.

Also when you click the map, you will find that the position of the marker is changed a little.

@pathmapper
Copy link
Contributor

Can't reproduce, for me it works.

Chrome 65.0.3325.181 on Linux

@jfirebaugh
Copy link
Contributor

Works for me too. @exotfboy is that the right example?

@exotfboy
Copy link
Author

I am sure I can not open none of the links when I post this issue, but now I found that the link can be opened sometime(not all). I will tried to make a video to verify that.

https://i.imgur.com/wGtnQS7.gif

@ttsirkia
Copy link

I was able to reproduce this with Google and Firefox. When clicking about 50 times, there is one click which doesn't do anything.

@ttsirkia
Copy link

Now when the example has been open a while, it seems that the probability to get a "broken link" is much higher. It is easier to reproduce this with Chrome.

@ttsirkia
Copy link

Also when you click the map, you will find that the position of the marker is changed a little.

The same occurs when you drag the map. I suspect that sometimes the click is considered as starting and stopping the dragging instead of clicking the link.

@jfirebaugh
Copy link
Contributor

jfirebaugh commented May 25, 2018

If you move the mouse between the mousedown and the mouseup, it's interpreted as a map drag rather than a click event. I suspect that's what's happening.

If you don't want to allow dragging the map via the marker element:

map.on('mousedown', function(e) {
    const target = e.originalEvent.target;
    if (target === marker.getElement() || marker.getElement().contains(target)) {
        e.preventDefault();
    }
});

@jfirebaugh
Copy link
Contributor

I've also reopened #1832 -- if you are interested in adding a click tolerance option, we'd welcome a PR.

@ttsirkia
Copy link

The issue can definitely be reproduced although the mouse doesn't move at all. For some reason, it is considered as drag start.

@jfirebaugh
Copy link
Contributor

I can reproduce a browser bug in Chrome that would cause this: https://bugs.chromium.org/p/chromium/issues/detail?id=721341

I guess the drag handler needs to filter out spurious move events.

@jfirebaugh jfirebaugh reopened this May 25, 2018
@exotfboy
Copy link
Author

As @ttsirkia said, the link can not be opened even I do not move the mouse.

@ttsirkia
Copy link

I tried this tool https://dvcs.w3.org/hg/d4e/raw-file/tip/mouse-event-test.html but couldn't get any spurious mousemove events.

@exotfboy
Copy link
Author

image

@ttsirkia
Copy link

That confirms the root cause. For some reason, it occurs more often for you. And I'm still wondering why I couldn't see the behavior with that tool.

@exotfboy
Copy link
Author

@ttsirkia @jfirebaugh

Thank you guys for the insistence of finding the root cause for this unusual issue.

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

No branches or pull requests

4 participants