diff --git a/src/ui/form-modal-ui-handler.ts b/src/ui/form-modal-ui-handler.ts index 5c547465de9..c6ef8705aa8 100644 --- a/src/ui/form-modal-ui-handler.ts +++ b/src/ui/form-modal-ui-handler.ts @@ -136,6 +136,11 @@ export abstract class FormModalUiHandler extends ModalUiHandler { this.submitAction = config.buttonActions.length ? config.buttonActions[0] : null; this.cancelAction = config.buttonActions[1] ?? null; + // Auto focus the first input field after a short delay, to prevent accidental inputs + setTimeout(() => { + this.inputs[0].setFocus(); + }, 50); + // #region: Override button pointerDown // Override the pointerDown event for the buttonBgs to call the `submitAction` and `cancelAction` // properties that we set above, allowing their behavior to change after this method terminates diff --git a/src/ui/pokedex-scan-ui-handler.ts b/src/ui/pokedex-scan-ui-handler.ts index 4f606cbcbb0..9be7a903dec 100644 --- a/src/ui/pokedex-scan-ui-handler.ts +++ b/src/ui/pokedex-scan-ui-handler.ts @@ -106,10 +106,6 @@ export class PokedexScanUiHandler extends FormModalUiHandler { this.reduceKeys(); - setTimeout(() => { - input.setFocus(); // Focus after a short delay to avoid unwanted input - }, 50); - input.on("keydown", (inputObject, evt: KeyboardEvent) => { if ( ["escape", "space"].some(v => v === evt.key.toLowerCase() || v === evt.code.toLowerCase()) &&