geoman-io / leaflet-geoman

🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.21k stars 433 forks source link

Problems in afterClick and onClick functions after to apply setButtonDisabled("nameBtn", false) #1161

Closed wdavila closed 2 years ago

wdavila commented 2 years ago

https://github.com/geoman-io/leaflet-geoman/blob/9297f87f29c98978fb6f70980b7327bfa3098202/src/js/Toolbar/L.Controls.js#L261-L275

I was using setButtonDisabled function to disable toolbar buttons. However, I could not enable onClick and afteClick functions after being disabled with this function.

I think that _updateDisabled function needed when this._button.disabled is False:

this.$L.DomEvent.on(button_, 'click', button._triggerClick, button) this.$L.DomEvent.on(button_, 'click', button._onBtnClick, button)

Whit this changes now onClick and afteClick option work well.

Falke-Design commented 2 years ago

Until #1165 is merged and released, you can call map.pm.Toolbar._showHideButtons(); after enabling the buttons.