From 2a433a41e95e4ad973f8efc1a0b2d26d338f6a5c Mon Sep 17 00:00:00 2001 From: Sirius DevOps Date: Thu, 27 Aug 2026 17:48:39 -0400 Subject: [PATCH] =?UTF-8?q?map:=20port=20master=20popup-guard=20fix=20?= =?UTF-8?q?=E2=80=94=20real=20popup=20state=20via=20events,=20close=20on?= =?UTF-8?q?=20zoom/drag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Master's b2369bc fixed cameras vanishing after opening a popup and zooming: Leaflet 1.9.4's Map.closePopup() never nulls map._popup, so the old 'if (map._popup) return' guard skipped every overlay reload forever after the first popup. Port the fix into the redesigned frontend: track popup state via popupopen/popupclose, close on user zoom/drag so moveend reloads always run, and keep the autopan skip for the popup's own pan. --- app/static/index.html | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/static/index.html b/app/static/index.html index 4c1efae..9afe27b 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -1621,11 +1621,22 @@ async function initMap() { if (activeHls) { try { activeHls.destroy(); } catch (_) {} activeHls = null; } }); updateHeatLegend(); - // Reload overlays when the user pans/zooms. Skip when a popup is open: - // opening a camera popup auto-pans the map to fit it, and that moveend - // must NOT rebuild the marker group under the open popup. + // Reload overlays when the user pans/zooms. A live popup makes the + // rebuild skip (so the popup's autopan doesn't destroy it), but user + // zoom/drag must close the popup FIRST — otherwise zooming out with a + // camera popup open leaves the stale, zoomed-in marker group on the + // map and the cameras "vanish" until a refresh. + // + // NOTE: `map._popup` is NOT a reliable open-check in Leaflet 1.9.4 — + // Map.closePopup() never nulls it, so once any popup has been opened + // it stays truthy forever. Track the real state via popupopen/close. + let camPopupOpen = false; + map.on('popupopen', () => { camPopupOpen = true; }); + map.on('popupclose', () => { camPopupOpen = false; }); + map.on('zoomstart', () => { if (camPopupOpen) map.closePopup(); }); + map.on('dragstart', () => { if (camPopupOpen) map.closePopup(); }); map.on('moveend', () => { - if (map._popup) return; + if (camPopupOpen) return; // only the popup's own autopan now if (firesOn) loadFires(); if (camsOn) loadCams(); if (blipsOn) loadBlips();