From 5182dcb4c3e060a6269d885634572888b92fd223 Mon Sep 17 00:00:00 2001 From: Axce Date: Fri, 2 Jan 2026 05:34:38 +0100 Subject: [PATCH] =?UTF-8?q?=C3=A7a=20marchotte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 6788313..7d80b08 100644 --- a/index.html +++ b/index.html @@ -597,12 +597,13 @@ // Custom input for horizontal definition const customH = document.createElement('div'); customH.style.display = 'flex'; + customH.style.flexDirection = 'column'; customH.style.gap = '8px'; customH.style.marginTop = '8px'; const inputH = document.createElement('input'); inputH.type = 'text'; inputH.value = grid[row][col].definitionH || ''; - inputH.style.flex = '1'; + inputH.style.width = '100%'; const saveH = document.createElement('button'); saveH.className = 'btn-primary'; saveH.textContent = 'Enregistrer (H)'; @@ -655,12 +656,13 @@ // Custom input for vertical definition const customV = document.createElement('div'); customV.style.display = 'flex'; + customV.style.flexDirection = 'column'; customV.style.gap = '8px'; customV.style.marginTop = '8px'; const inputV = document.createElement('input'); inputV.type = 'text'; inputV.value = grid[row][col].definitionV || ''; - inputV.style.flex = '1'; + inputV.style.width = '100%'; const saveV = document.createElement('button'); saveV.className = 'btn-primary'; saveV.textContent = 'Enregistrer (V)'; @@ -1066,6 +1068,14 @@ if (e.ctrlKey || e.altKey || e.metaKey) return; if (document.getElementById('gridScreen').style.display === 'none') return; + // If modal is open, do not interact with grid via keyboard + const modal = document.getElementById('definitionModal'); + if (modal.classList.contains('show')) return; + + // don't intercept when focus is inside an input/textarea/contentEditable + const ae = document.activeElement; + if (ae && (ae.tagName === 'INPUT' || ae.tagName === 'TEXTAREA' || ae.isContentEditable)) return; + // Toggle orientation with Tab when an active cell exists if (e.key === 'Tab') { if (!activeCell) return; @@ -1078,6 +1088,17 @@ if (!activeCell) return; const { row, col } = activeCell; + // Delete key: transform active cell into empty letter + if (e.key === 'Delete') { + e.preventDefault(); + grid[row][col].type = 'letter'; + grid[row][col].letter = ''; + grid[row][col].definitionH = ''; + grid[row][col].definitionV = ''; + renderGrid(); + return; + } + // Enter: transform empty letter into definition (or open modal if definition exists) if (e.key === 'Enter') { e.preventDefault();