fix(host-detail): fix add-app modal not reopening after successful addition
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,19 @@ fn AddAppModal(
|
|||||||
// Full Application structs so names are available in the selected tag list.
|
// Full Application structs so names are available in the selected tag list.
|
||||||
let selected: RwSignal<Vec<Application>> = RwSignal::new(vec![]);
|
let selected: RwSignal<Vec<Application>> = RwSignal::new(vec![]);
|
||||||
|
|
||||||
|
// Close the modal when the action transitions from in-flight → completed with Ok.
|
||||||
|
// Tracking the pending→false transition (rather than watching value directly) avoids
|
||||||
|
// closing the modal on mount when value still holds a previous session's Ok result.
|
||||||
|
Effect::new(move |was_pending: Option<bool>| {
|
||||||
|
let is_pending = add_action.pending().get();
|
||||||
|
if was_pending == Some(true) && !is_pending {
|
||||||
|
if let Some(Ok(_)) = add_action.value().get() {
|
||||||
|
show_modal.set(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is_pending
|
||||||
|
});
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="modal-backdrop" on:click=move |_| show_modal.set(false)>
|
<div class="modal-backdrop" on:click=move |_| show_modal.set(false)>
|
||||||
<div class="modal" on:click=move |e| e.stop_propagation()>
|
<div class="modal" on:click=move |e| e.stop_propagation()>
|
||||||
@@ -245,15 +258,6 @@ pub fn HostDetailPage() -> impl IntoView {
|
|||||||
let show_delete_modal = RwSignal::new(false);
|
let show_delete_modal = RwSignal::new(false);
|
||||||
let show_add_app_modal = RwSignal::new(false);
|
let show_add_app_modal = RwSignal::new(false);
|
||||||
|
|
||||||
// Auto-close the add-app modal after a successful addition.
|
|
||||||
// Keeping this Effect in the parent avoids the re-trigger bug that would
|
|
||||||
// occur if the Effect were inside AddAppModal (it would fire on mount
|
|
||||||
// if the action already held a previous Ok value).
|
|
||||||
Effect::new(move |_| {
|
|
||||||
if let Some(Ok(_)) = add_app_action.value().get() {
|
|
||||||
show_add_app_modal.set(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// LocalResource avoids reading the resource outside <Suspense> during hydration,
|
// LocalResource avoids reading the resource outside <Suspense> during hydration,
|
||||||
// which would cause a mismatch between the SSR-rendered fallback and the content
|
// which would cause a mismatch between the SSR-rendered fallback and the content
|
||||||
|
|||||||
Reference in New Issue
Block a user