From 8e9dc9f6f8ee53af8703d2d105caab9b150ef70f Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Fri, 30 Aug 2024 16:52:18 +0530 Subject: [PATCH] update: point fix at correct place. --- src/lib/elements/forms/inputDigits.svelte | 29 ++----------------- .../(public)/(guest)/login/+page.svelte | 11 ------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/src/lib/elements/forms/inputDigits.svelte b/src/lib/elements/forms/inputDigits.svelte index 1632e92ce..c100d5a73 100644 --- a/src/lib/elements/forms/inputDigits.svelte +++ b/src/lib/elements/forms/inputDigits.svelte @@ -54,41 +54,16 @@ } } - 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); - + onMount(() => { const interval = setInterval(() => { const input = element.querySelector('input'); if (element) { - /** - * Ensure the value is empty before refocusing. - * - * If the value is not cleared and the form is submitted, - * the cursor will move to the first field while the last field remains filled. - * This would cause the focus to appear visually odd and very inconsistent. - */ - if (input && autofocus && value === '') { + if (input && autofocus) { input.focus(); } 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(); - }); }); diff --git a/src/routes/(public)/(guest)/login/+page.svelte b/src/routes/(public)/(guest)/login/+page.svelte index fee71f180..a08230da9 100644 --- a/src/routes/(public)/(guest)/login/+page.svelte +++ b/src/routes/(public)/(guest)/login/+page.svelte @@ -51,17 +51,6 @@ await goto(`${base}/apply-credit?campaign=${data.campaign}`); return; } - if ($page.url.searchParams) { - const redirect = $page.url.searchParams.get('redirect'); - $page.url.searchParams.delete('redirect'); - if (redirect) { - await goto(`${redirect}${$page.url.search}`); - } else { - await goto(`${base}${$page.url.search ?? ''}`); - } - } else { - await goto(base); - } } catch (error) { disabled = false; addNotification({