From fdfe1072d83f60a208e18aec39cd42b2c51fb4a4 Mon Sep 17 00:00:00 2001 From: Adriano Dal Pastro Date: Fri, 5 Jun 2026 09:11:31 +0000 Subject: [PATCH] =?UTF-8?q?fix(measure):=20supervisor=20modal=20=E2=80=94?= =?UTF-8?q?=20backspace=20works=20and=20fields=20reset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two issues with the "Autorizzazione capoturno" modal: 1. Backspace and digits did not work in the username/password fields. The numpad component installs a window-level keydown handler (for the USB caliper / keyboard wedge) that preventDefault()s digits, Backspace, Enter etc. It swallowed those keys inside the modal inputs. Guard handleKeydown to ignore events whose target is an editable field (INPUT/TEXTAREA/SELECT/ contentEditable); the numpad has no text inputs of its own. 2. The modal kept the previous username/password: opening only set the flag, and closing via backdrop click did not clear the fields. Add openSupervisorModal()/closeSupervisorModal() that always reset username, password and error, and use them for every open (fermo_linea, fine_produzione, out_of_tolerance) and close (backdrop, Annulla). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/frontend/flask_app/static/js/numpad.js | 11 ++++++++ .../templates/measure/task_execute.html | 27 ++++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/frontend/flask_app/static/js/numpad.js b/src/frontend/flask_app/static/js/numpad.js index 7a077f3..70154ec 100644 --- a/src/frontend/flask_app/static/js/numpad.js +++ b/src/frontend/flask_app/static/js/numpad.js @@ -163,6 +163,17 @@ function numpad() { * @param {KeyboardEvent} e - The keyboard event */ handleKeydown(e) { + // Ignore keystrokes aimed at an editable field (e.g. the supervisor + // login modal). The numpad has no text inputs of its own, so this + // window-level capture is only meant for the USB caliper / keyboard + // wedge when no field is focused. Without this guard the numpad would + // swallow digits and Backspace inside those inputs. + const t = e.target; + if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || + t.tagName === 'SELECT' || t.isContentEditable)) { + return; + } + // Number keys if (e.key >= '0' && e.key <= '9') { e.preventDefault(); diff --git a/src/frontend/flask_app/templates/measure/task_execute.html b/src/frontend/flask_app/templates/measure/task_execute.html index 198579d..0ab1f52 100644 --- a/src/frontend/flask_app/templates/measure/task_execute.html +++ b/src/frontend/flask_app/templates/measure/task_execute.html @@ -116,14 +116,14 @@ {# Fermo linea + Fine produzione (measurement tasks only) #}