diff --git a/src/client/applications.rs b/src/client/applications.rs index e5cd526..8fc67d8 100644 --- a/src/client/applications.rs +++ b/src/client/applications.rs @@ -8,6 +8,7 @@ use leptos::prelude::*; use leptos::form::ActionForm; +use leptos::html::Input; use crate::api::applications::{ ApplicationWithCounts, CreateApplication, DeleteApplication, @@ -21,9 +22,12 @@ fn AddApplicationModal( create_action: ServerAction, show_modal: RwSignal, ) -> impl IntoView { + let name_ref = NodeRef::::new(); + + // Focus the name field as soon as the modal is mounted. Effect::new(move |_| { - if let Some(Ok(_)) = create_action.value().get() { - show_modal.set(false); + if let Some(el) = name_ref.get() { + let _ = el.focus(); } }); @@ -43,6 +47,7 @@ fn AddApplicationModal(