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(); });