diff --git a/frontend/js/backups.js b/frontend/js/backups.js index 79c0552..cfd92c9 100644 --- a/frontend/js/backups.js +++ b/frontend/js/backups.js @@ -83,6 +83,19 @@ function createOverlay() { panel.id = 'backup-viewer-panel'; overlay.appendChild(panel); + // Close button OUTSIDE the panel — never touched by innerHTML, always present + const closeBtn = document.createElement('button'); + closeBtn.className = 'editor-btn backup-close-btn'; + closeBtn.id = 'backup-close'; + closeBtn.title = 'Fermer'; + closeBtn.style.cssText = 'position:absolute;top:12px;right:12px;z-index:1002;flex-shrink:0'; + closeBtn.innerHTML = ''; + closeBtn.addEventListener('click', (e) => { + e.stopPropagation(); + close(); + }); + overlay.appendChild(closeBtn); + // Keyboard: Escape closes the viewer _escHandler = (e) => { if (e.key === 'Escape' && state.overlay) close(); @@ -92,20 +105,10 @@ function createOverlay() { return overlay; } -/** Replace panel content and re-bind the close button. */ +/** Replace panel content. Close button is static in the overlay, never replaced. */ function setBody(html) { const panel = document.getElementById('backup-viewer-panel'); - if (!panel) return; - panel.innerHTML = html; - safeCreateIcons(); - // Bind close button — same pattern as AdminPanel - const closeBtn = panel.querySelector('.backup-close-btn'); - if (closeBtn) { - closeBtn.addEventListener('click', (e) => { - e.stopPropagation(); - close(); - }); - } + if (panel) panel.innerHTML = html; } let _escHandler = null; @@ -127,14 +130,10 @@ function close() { // Rendering // --------------------------------------------------------------------------- -/** Close button HTML — same pattern as AdminPanel editor-btn */ -const CLOSE_BTN = ''; - function renderLoading() { return `
${escapeHtml(msg)}
@@ -156,10 +154,9 @@ function renderError(msg) { } function renderEmpty() { - return ` + return \`Aucun backup disponible pour ce fichier.
@@ -189,8 +186,7 @@ function renderMainView() { ${escapeHtml(state.path)}