fix(measure): supervisor modal — backspace works and fields reset

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) <noreply@anthropic.com>
This commit is contained in:
Adriano Dal Pastro
2026-06-05 09:11:31 +00:00
parent 6ff78b2150
commit fdfe1072d8
2 changed files with 32 additions and 6 deletions
@@ -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();