Leaflet / Leaflet.draw

Vector drawing and editing plugin for Leaflet
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
MIT License
1.98k stars 994 forks source link

Click not triggering on DOM elements when in draw mode on mobile browsers #928

Closed berniesf closed 5 years ago

berniesf commented 5 years ago

How to reproduce

What behaviour I'm expecting and which behaviour I'm seeing

Minimal example reproducing the issue

I created a jsfiddle and a StackOverflow question:

https://jsfiddle.net/fsv8jegd/2/

https://stackoverflow.com/questions/56030563/leaflet-draw-preventing-click-on-elements-while-is-active

berniesf commented 5 years ago

I found a solution. The line 1260 of the leaflet.draw 1.0.4 contains the following code:

document.addEventListener('touchstart', L.DomEvent.preventDefault, { passive: false });

I replaced that line with

var tempMap = document.getElementById("map"); tempMap.addEventListener('touchstart', L.DomEvent.preventDefault, { passive: false });

Basically instead of preventing the touchstart event on the document, now is applied only to the map object.

johnd0e commented 5 years ago

Duplicate #922 Another fix: #930

johnd0e commented 4 years ago

Original issue is not reproduced anymore with new Leaflet 1.6. (Perhaps fixed by https://github.com/Leaflet/Leaflet/pull/6694)