From 7f68b2e9c47a420cb2903ba342e1dfe9e68d153f Mon Sep 17 00:00:00 2001 From: megrogan Date: Sun, 30 Jun 2024 16:27:56 +0100 Subject: [PATCH] Android hack not needed in "numeric" mode [shrug] --- frontend/app/src/components/pincode/PincodeInput.svelte | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/app/src/components/pincode/PincodeInput.svelte b/frontend/app/src/components/pincode/PincodeInput.svelte index 1c99b1fd1e..fdfdf3032d 100644 --- a/frontend/app/src/components/pincode/PincodeInput.svelte +++ b/frontend/app/src/components/pincode/PincodeInput.svelte @@ -9,9 +9,10 @@ export let selectTextOnFocus: boolean = false; let ref: HTMLInputElement | undefined; - let userAgent = navigator.userAgent; - const android = userAgent?.match(/android/i); + const android = (navigator.userAgent?.match(/android/i) ?? undefined) !== undefined; + const androidHack = type === "alphanumeric" && android; + const KEYBOARD = { CONTROL: "Control", COMMAND: "Meta", @@ -32,7 +33,7 @@ } function onInput(e: Event) { - if (android) { + if (androidHack) { // Get latest char from the input value const target = e.target as HTMLInputElement; const latestChar = target.value[target.value.length - 1]; @@ -73,7 +74,7 @@ } // Do not try to update the value from the keydown event if on android, leave that to the input event - if (!android) { + if (!androidHack) { dispatchUpdate(e.key); } }}