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 dragging is re-enabled when layerControl overlay is toggled off and on. #7389

Open
5 tasks done
ask-anton opened this issue Dec 22, 2020 · 1 comment
Open
5 tasks done
Labels

Comments

@ask-anton
Copy link

  • I've looked at the documentation to make sure the behavior is documented and expected.
  • I'm sure this is a Leaflet code issue, not an issue with my own code nor with the framework I'm using (plain JS, leaflet).
  • I've searched through the issues to make sure it's not yet reported.

Steps to reproduce
Steps to reproduce the behavior:

  • Initialize the LayerGroup, layerControl, add them to the map.
  • Initialize the Marker with draggable: true.
  • Add the marker to the LayerGroup, and add the LayerGroup to the map.
  • Disable the dragging for each layer of the Layer Group. The marker becomes un-draggable on the map.
  • Hide the marker, by unchecking the overlay in the the layerControl box. No marker is shown on the map.
  • Show the marker, by checking the overlay in the the layerControl box. The marker becomes draggable on the map.

Expected behavior

After the marker is shown again on the map by checking the overlay in the layerControl box, expecting the marker to stay un-draggable.

Current behavior

After the marker is shown again on the map by checking the overlay in the layerControl box, the marker reverts to the original state of being draggable.

Environment

  • Leaflet version: 1.7.1
  • Browser (with version): Chrome Version 87.0.4280.88 (Official Build) (64-bit)
  • OS/Platform (with version): Windows 10 Home 20H2 19042.685

Additional context

Minimal example reproducing the issue
http://jsfiddle.net/71keLoaf/1/

  • this example is as simple as possible
  • this example does not rely on any third party code
@johnd0e
Copy link
Collaborator

johnd0e commented Dec 22, 2020

I tend to agree that this behavior is a bug.

But not completely sure.
Here is some actions to set draggable option enabled after layer removed, but no action if handler is disabled.

onRemove: function (map) {
if (this.dragging && this.dragging.enabled()) {
this.options.draggable = true;
this.dragging.removeHooks();
}
delete this.dragging;

Still it's not clear to me why it is implemented like that: it would be simpler just keeping option in sync always.

@IvanSanchez
That was your change: db8a790

@johnd0e johnd0e added the bug label Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants