From 237ceab042791c583ccd56b9b33fcd2349aa60f8 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 5 Jul 2026 22:03:23 +0000 Subject: [PATCH] fix: ao fechar preview, reabrir modal confirmacao se ainda estava aberto --- src/index.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/index.html b/src/index.html index df4cf9e..4499dac 100644 --- a/src/index.html +++ b/src/index.html @@ -1833,14 +1833,12 @@ function openPrintPreview(data, mode) { background: #444; color: #fff; border: none; border-radius: 6px; font-size: 15px; cursor: pointer; `; - // Salva qual modal estava aberto antes do preview (para reabrir ao fechar) - const modalConfirmOpen = document.getElementById('modal-confirm')?.classList.contains('open'); - btnFechar.onclick = () => { document.body.removeChild(overlay); - // Se o modal de confirmação estava aberto antes, reabre ele - if (modalConfirmOpen) { - document.getElementById('modal-confirm').classList.add('open'); + // Garante que o modal de confirmação volte a aparecer (caso ainda tenha a classe 'open') + const modalConfirm = document.getElementById('modal-confirm'); + if (modalConfirm && !modalConfirm.classList.contains('open')) { + modalConfirm.classList.add('open'); } }; @@ -2052,6 +2050,8 @@ document.getElementById('confirm-cancel').addEventListener('click', closeConfirm document.getElementById('modal-confirm').addEventListener('click', e => { if (e.target.id === 'modal-confirm') closeConfirmModal(); }); // Print from confirm modal — abre preview idêntico ao modal de confirmação +// Não fecha o modal aqui — o preview é um overlay por cima; quando fechar o preview, +// o modal já estará visível por baixo (continua no DOM, só que coberto) document.getElementById('confirm-print').addEventListener('click', async () => { // Usa buildReciboData para não duplicar lógica e ter todos os campos certos let data; @@ -2062,8 +2062,7 @@ document.getElementById('confirm-print').addEventListener('click', async () => { alert('Erro ao montar dados do recibo.'); return; } - // Fecha modal APÓS gerar preview (não antes) - closeConfirmModal(); + // NÃO fecha o modal aqui — só abre o preview por cima openPrintPreview(data, 'report'); });