brunob / leaflet.fullscreen

Leaflet.Control.FullScreen for Leaflet
https://brunob.github.io/leaflet.fullscreen/
MIT License
376 stars 107 forks source link

Button state incorrect when multiple maps on a page #117

Closed skirridsystems closed 8 months ago

skirridsystems commented 8 months ago

If there are multiple maps on a page, e.g. showing different walking routes in an area, if you enter and then exit fullscreen on one map, the fullscreen button on all the other maps then shows the exit fullscreen icon and text, even though they are clearly not fullscreened.

This only affects buttons which have not yet been clicked. If I then fullscreen/exit on a different map, the first map to be fullscreened shows the correct icon state.

brunob commented 8 months ago

Nice catch !

brunob commented 8 months ago

'k the bug come from _handleFullscreenChange() which is fired on fullscreenchange event for every map on the page leading to the bug :\

This come from https://github.com/brunob/leaflet.fullscreen/blob/master/Control.FullScreen.js#L178 which was introduced to handle fullscreenchange on exit key press.

We have to find a workaround, something inspired by https://github.com/Leaflet/Leaflet.fullscreen/blob/gh-pages/dist/Leaflet.fullscreen.js#L120