[UI/UX] Auto focus first input field (#6413)

This commit is contained in:
Fabi 2025-09-04 11:31:52 +02:00 committed by GitHub
parent 4a28773929
commit ddde977a0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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()) &&