I have an issue which causes different problems in different browsers.
I create a simple map and added a few markers, and when I click anywhere in the map the following happens depending on which browser I use:
The code is fairly integrated into my project, so it's a bit difficult to extract something that'll be useful to you guys, I'm just looking for a pointer in the right direction of where the problem could lie.
Thanks!
I also noticed that if I do
_map.on("click", function(ev) {console.log(ev)});
, it misses the first click. This is probably related.
Do you have something in your code that is listening to mouse down/up?
Sounds like the bug is something in your code, but I have no idea what.
Does it make a JS error in firefox?
I can't seem to find a reason for this bug in my code, and the same symptoms appear on http://www.mapsmarker.com/ (in IE and Chrome). It also appears that this only happens when the entire map canvas is not in view when the first click is fired.
I was able to reproduce this in a jsfiddle:
Hopefully you understand what I mean.
Hmm, my guess is that it's the default browser behavior — when an element gets focus, it scrolls the window so that it's fully in the view. Need to check this to confirm.
You can of course fix this by disabling keyboard navigation (keyboard: false in map options) but that's not a very good option.
Yeah, that "solves" the issue in chrome, but the half-way fade-in is still present in Firefox, and frankly, looks more buggy than the jump in Chrome.
Noticed the same thing. And it seems that evt.originalEvent.preventDefault() doesn't help either.
Here's a dirty dirty hack that resolves the problem:
L.Map.addInitHook(function() {
return L.DomEvent.off(this._container, "mousedown", this.keyboard._onMouseDown);
});
Should be fixed now (even with keyboard enabled), please try this out.
Still broken as of 0.5.1
@tjwebb it's a master version fix
I still experience this issue with bower's v0.7.3 (that should already have the patch, right?) - on click the map scrolls content up and disabling keyboard access fixes the issue.
It's fixed on master. But the commit b61b7b4 shows that's in tag 0.7.3...
This is still an issue on Chrome as of today ( 14/05/15 ).
As noted by a comment in commit b61b7b4 by @Matheo13, removing this._map._container.focus(); line (7743 in leaflet-src 0.7.3) fixes the bug.
@nilguncelik it's a master version fix (2).
I saw something same issue in 1.0.3. My page scrolling up when I clicked the map after popup.
No such issue in 0.7.7.
Issue going off when I commented string #12077:
window.scrollTo(left, top);
@slako this is an old and closed issue. If you believe you have found a similar issue, please open a new one, clearly stating the problem, and the platform you're seeing it on, and preferably also an example reproducing it.
Hi Folks, I still faced this issue. I added ID to the map by passing prop => id='mapDiv'
then in React hooks adding below effect
useEffect(() => {
document.getElementById('mapDiv').focus();
});
Most helpful comment
I saw something same issue in 1.0.3. My page scrolling up when I clicked the map after popup.
No such issue in 0.7.7.
Issue going off when I commented string #12077:
window.scrollTo(left, top);