mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 15:03:24 +02:00
[UI/UX] Auto focus first input field (#6413)
This commit is contained in:
parent
4a28773929
commit
ddde977a0a
@ -136,6 +136,11 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
|
|||||||
this.submitAction = config.buttonActions.length ? config.buttonActions[0] : null;
|
this.submitAction = config.buttonActions.length ? config.buttonActions[0] : null;
|
||||||
this.cancelAction = config.buttonActions[1] ?? 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
|
// #region: Override button pointerDown
|
||||||
// Override the pointerDown event for the buttonBgs to call the `submitAction` and `cancelAction`
|
// 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
|
// properties that we set above, allowing their behavior to change after this method terminates
|
||||||
|
@ -106,10 +106,6 @@ export class PokedexScanUiHandler extends FormModalUiHandler {
|
|||||||
|
|
||||||
this.reduceKeys();
|
this.reduceKeys();
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
input.setFocus(); // Focus after a short delay to avoid unwanted input
|
|
||||||
}, 50);
|
|
||||||
|
|
||||||
input.on("keydown", (inputObject, evt: KeyboardEvent) => {
|
input.on("keydown", (inputObject, evt: KeyboardEvent) => {
|
||||||
if (
|
if (
|
||||||
["escape", "space"].some(v => v === evt.key.toLowerCase() || v === evt.code.toLowerCase()) &&
|
["escape", "space"].some(v => v === evt.key.toLowerCase() || v === evt.code.toLowerCase()) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user