Skip to content

Commit

Permalink
Prevent adding layer while expanding Layer-Control on mobile (#8910)
Browse files Browse the repository at this point in the history
  • Loading branch information
Falke-Design committed May 18, 2023
1 parent af165dd commit 6e026b0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/control/Control.Layers.js
Expand Up @@ -83,6 +83,7 @@ export var Layers = Control.extend({
this._layers = [];
this._lastZIndex = 0;
this._handlingClick = false;
this._preventClick = false;

for (var i in baseLayers) {
this._addLayer(baseLayers[i], i);
Expand Down Expand Up @@ -358,6 +359,11 @@ export var Layers = Control.extend({
},

_onInputClick: function () {
// expanding the control on mobile with a click can cause adding a layer - we don't want this
if (this._preventClick) {
return;
}

var inputs = this._layerControlInputs,
input, layer;
var addedLayers = [],
Expand Down Expand Up @@ -417,10 +423,13 @@ export var Layers = Control.extend({

_expandSafely: function () {
var section = this._section;
this._preventClick = true;
DomEvent.on(section, 'click', DomEvent.preventDefault);
this.expand();
var that = this;
setTimeout(function () {
DomEvent.off(section, 'click', DomEvent.preventDefault);
that._preventClick = false;
});
}

Expand Down

0 comments on commit 6e026b0

Please sign in to comment.