From 7ae607cc50fc3cd7f912f48ada2deb37a582fa14 Mon Sep 17 00:00:00 2001 From: E44 <129310925+programmer-44@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:12:26 +0100 Subject: [PATCH] chore(control): add focus_on_start to TextInput --- .../frontend/src/components/TextInput.svelte | 20 +++++++++---------- control/frontend/src/routes/+page.svelte | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/control/frontend/src/components/TextInput.svelte b/control/frontend/src/components/TextInput.svelte index 118abb3..6b49fc4 100644 --- a/control/frontend/src/components/TextInput.svelte +++ b/control/frontend/src/components/TextInput.svelte @@ -10,7 +10,8 @@ bg = 'bg-stone-750', title, placeholder = '', - is_valid_function = null + is_valid_function = null, + focused_on_start = false } = $props<{ current_value: string; current_valid: boolean; @@ -19,11 +20,13 @@ title: string; placeholder?: string; is_valid_function?: ((input: string) => [boolean, string]) | null; + focused_on_start?: boolean; }>(); let focus_bg = get_shifted_color(bg, 100); - let focussed = $state(false); + let focused: boolean = $state(false); let current_info = $state(''); + let input_element: HTMLInputElement; function validate_input() { if (!is_valid_function) return; @@ -40,15 +43,16 @@ } onMount(() => { validate_input(); + if (focused_on_start && input_element) input_element.focus(); });