Skip to content

Commit

Permalink
Android hack not needed in "numeric" mode [shrug]
Browse files Browse the repository at this point in the history
  • Loading branch information
megrogan committed Jun 30, 2024
1 parent 4271847 commit 7f68b2e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions frontend/app/src/components/pincode/PincodeInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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];
Expand Down Expand Up @@ -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);
}
}}
Expand Down

0 comments on commit 7f68b2e

Please sign in to comment.