jjimenezshaw / Leaflet.Control.Layers.Tree

a Tree Layers Control for Leaflet
https://jjimenezshaw.github.io/Leaflet.Control.Layers.Tree/examples/basic.html
BSD 3-Clause "New" or "Revised" License
146 stars 36 forks source link

Prevent adding layer while expanding Layer-Control on mobile #67

Closed PedroVenancio closed 11 months ago

PedroVenancio commented 1 year ago

Hi @jjimenezshaw

This issue is related to https://github.com/Leaflet/Leaflet/issues/8778 that was fixed in Leaflet 1.9.4 with https://github.com/Leaflet/Leaflet/pull/8910

However, the PR only fix the L.control.layers. Using Leaflet.Control.Layers.Tree it keeps with the same behaviour, as you can test here:

https://plnkr.co/edit/W135NFAEtQV0a3ZK

https://run.plnkr.co/plunks/W135NFAEtQV0a3ZK

It seems that the fix applied to L.control.layers also needs to be added in Leaflet.Control.Layers.Tree

jjimenezshaw commented 1 year ago

Hi @PedroVenancio In your first link it is still using leaflet 1.9.3 Maybe if you use leaflet 1.9.4 it works. I do not see what I should change in the plugin code to apply that bugfix. It is already in L.control.layers.

PedroVenancio commented 1 year ago

Hi @jjimenezshaw

In your first link it is still using leaflet 1.9.3 Maybe if you use leaflet 1.9.4 it works.

In these examples I was using Leaflet 1.9.3 but the changes applied in the fix were in the code.

Unfortunately, using Leaflet 1.9.4 does not solve the problem either:

https://plnkr.co/edit/Jkfw8kZMVEeaIsWT https://run.plnkr.co/plunks/Jkfw8kZMVEeaIsWT

I do not see what I should change in the plugin code to apply that bugfix. It is already in L.control.layers.

@Falke-Design do you have any hint to fix this issue in Leaflet.Control.Layers.Tree side?

jjimenezshaw commented 1 year ago

Just to clarify, what I noticed in the example in plnkr is that opening the menu collapses or expands the tree, that is the effect of clicking on the first row.

PedroVenancio commented 1 year ago

Hi @jjimenezshaw That's correct, when clicking to open the Layers Control on a mobile device, that click is at the same time applied to the layer or menu in the list, what causes the collapse or expand of the tree. It is somewhat like double-clicking to open the control and clicking on the menu, but it happens only with one click.

PedroVenancio commented 1 year ago

Hi @jjimenezshaw I would like to help solving this issue, but I don't know how. @Falke-Design do you have any hint?