diff --git a/assets/plugins/features/autosubmit.ts b/assets/plugins/features/autosubmit.ts index 540e347e..10d60388 100644 --- a/assets/plugins/features/autosubmit.ts +++ b/assets/plugins/features/autosubmit.ts @@ -66,17 +66,20 @@ export class AutosubmitPlugin implements DatagridPlugin { ); } - submitEl.addEventListener( - "keyup", - debounce(e => { - // Ignore keys such as alt, ctrl, etc, F-keys... (when enter is not pressed) - if (!isEnter(e) && (isInKeyRange(e, 9, 40) || isFunctionKey(e))) { - return; - } - - return datagrid.ajax.submitForm(form); - }) - ); + const debouncedSubmit = debounce(() => datagrid.ajax.submitForm(form)); + submitEl.addEventListener("keyup", (e) => { + // Enter submits immediately, no debounce wait. + if (isEnter(e)) { + datagrid.ajax.submitForm(form); + return; + } + // Skip alt/ctrl/etc and F-keys here, not inside debounce — a late + // modifier keyup would otherwise overwrite the debounced submit's target. + if (isInKeyRange(e, 9, 40) || isFunctionKey(e)) { + return; + } + debouncedSubmit(); + }); } }); } diff --git a/assets/utils.ts b/assets/utils.ts index 65cd07db..3e057298 100644 --- a/assets/utils.ts +++ b/assets/utils.ts @@ -7,8 +7,8 @@ export function isPromise(p: any): p is Promise { export function isInKeyRange(e: KeyboardEvent, min: number, max: number): boolean { if (e.key.length !== 1) { // Named keys (Tab, Shift, ArrowLeft, etc.) are always considered in range - if (e.key === 'Backspace' || e.key === 'Delete') { - return false; // Editing keys change the input value and should still trigger autosubmit + if (e.key === 'Backspace' || e.key === 'Delete' || e.key === 'Unidentified') { + return false; // Editing keys (and the virtual-keyboard placeholder) change the input value and should still trigger autosubmit } return true; }