mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: mfa digits losing focus.
This commit is contained in:
1 parent
6e89654413
commit
d8b5d3a0d8
1 file changed
+21
-1
@@ -2,6 +2,8 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem } from '.';
|
||||
import { createPinInput, melt } from '@melt-ui/svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { sleep } from '$lib/helpers/promises';
|
||||
|
||||
export let length: number = 6;
|
||||
export let value: string = '';
|
||||
@@ -38,7 +40,13 @@
|
||||
}
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
async function focusDigitInputs() {
|
||||
/**
|
||||
* this is to re-focus the inputs that feels natural
|
||||
* as the blinking of the cursor takes around 250ms.
|
||||
*/
|
||||
await sleep(250);
|
||||
|
||||
const interval = setInterval(() => {
|
||||
const input = element.querySelector('input');
|
||||
if (element) {
|
||||
@@ -48,6 +56,18 @@
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
/**
|
||||
* Inputs will lose focus on any change.
|
||||
* Changes include the url & query params like `?redirect=`.
|
||||
*
|
||||
* This subscription ensures that focus is restored when needed.
|
||||
*/
|
||||
return page.subscribe(() => {
|
||||
focusDigitInputs();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in new issue
Block a user