diff --git a/frontend/js/main.js b/frontend/js/main.js index 9162bde..edfa675 100644 --- a/frontend/js/main.js +++ b/frontend/js/main.js @@ -1921,8 +1921,9 @@ async function showGoalMarkersModal() { btn.onclick = async (e) => { e.stopPropagation(); await DB.deleteGoalMarker(parseInt(btn.dataset.mid)); - // Refresh modal - overlay.remove(); + // Close and reopen modal + if (winStack.length > 0) winStack.pop().close(); + _skipPops = 1; history.back(); showGoalMarkersModal(); }; @@ -1930,7 +1931,8 @@ async function showGoalMarkersModal() { // Add button overlay.querySelector("#gm-add").onclick = () => { - overlay.remove(); + if (winStack.length > 0) winStack.pop().close(); + _skipPops = 1; history.back(); showAddGoalMarkerModal(); }; @@ -2830,7 +2832,8 @@ async function showSessionDetail(sessionId) { recalcBtn.disabled = false; if (newStats) { // Close modal and reopen with fresh data - document.querySelector(".modal-overlay")?.remove(); + if (winStack.length > 0) winStack.pop().close(); + _skipPops = 1; history.back(); showSessionDetail(sessionId); } @@ -3010,7 +3013,8 @@ async function showCompareModal(sessionId, currentSession, currentPoints) { item.onclick = async () => { const compId = parseInt(item.dataset.sid); // Close this modal, open comparison view - overlay.remove(); + if (winStack.length > 0) winStack.pop().close(); + _skipPops = 1; history.back(); await showComparisonView(sessionId, compId, currentSession, currentPoints); }; @@ -3323,7 +3327,8 @@ function showEditSupplementModal(existing) { delBtn.onclick = async (e) => { e.stopPropagation(); await DB.deleteSupplement(existing.id); - document.querySelector(".modal-overlay")?.remove(); + if (winStack.length > 0) winStack.pop().close(); + _skipPops = 1; history.back(); renderScreen("supplements"); }; @@ -3730,7 +3735,8 @@ async function showBikeModal(bikeId) { delBtn.onclick = async (e) => { e.stopPropagation(); await DB.deleteBike(bikeId); - document.querySelector(".modal-overlay")?.remove(); + if (winStack.length > 0) winStack.pop().close(); + _skipPops = 1; history.back(); renderScreen("settings"); };