diff --git a/src/components/Map/markerManager.js b/src/components/Map/markerManager.js index ff3f530..abb4f33 100644 --- a/src/components/Map/markerManager.js +++ b/src/components/Map/markerManager.js @@ -323,12 +323,13 @@ function normalizeImageUrl(raw) { return value; } -function closeCenteredOverlay(map) { +function closeCenteredOverlay(map, opts = {}) { try { const ov = map?.__swCenteredOverlay; if (!ov) return; if (ov.closing) return; ov.closing = true; + const skipHistory = !!opts.skipHistory; if (ov.onKey) window.removeEventListener("keydown", ov.onKey); if (ov.onAuth) window.removeEventListener("sociowire:auth-changed", ov.onAuth); @@ -352,7 +353,7 @@ function closeCenteredOverlay(map) { map.__swCenteredOverlay = null; - if (ov.historyPushed && !ov.historyClosed) { + if (!skipHistory && ov.historyPushed && !ov.historyClosed) { ov.historyClosed = true; try { window.history.back(); } catch {} } @@ -535,7 +536,10 @@ export function openCenteredOverlay({ map, post, theme, fullScreen = false }) { } onPop = () => { const ov = map.__swCenteredOverlay; - if (ov && ov.postId === postID) closeCenteredOverlay(map); + if (ov && ov.postId === postID) { + ov.historyClosed = true; + closeCenteredOverlay(map, { skipHistory: true }); + } }; window.addEventListener("popstate", onPop); } catch {}