From 52fd512554b543d9fae631e4cd7175dc880f5778 Mon Sep 17 00:00:00 2001 From: spinline Date: Sat, 31 Jan 2026 13:30:23 +0300 Subject: [PATCH] fix: resolve context menu race condition and add debug logs --- frontend/src/app.rs | 2 ++ frontend/src/components/context_menu.rs | 5 +++-- frontend/src/components/modal.rs | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/app.rs b/frontend/src/app.rs index d4de18e..e650e66 100644 --- a/frontend/src/app.rs +++ b/frontend/src/app.rs @@ -647,7 +647,9 @@ pub fn App() -> impl IntoView { torrent_hash=cm_target_hash.get() on_close=Callback::from(move |_| set_cm_visible.set(false)) on_action=Callback::from(move |(action, hash): (String, String)| { + logging::log!("App: Received action '{}' for hash '{}'", action, hash); if action == "delete" || action == "delete_with_data" { + logging::log!("App: Showing delete modal"); set_pending_action.set(Some((action, hash))); set_show_delete_modal.set(true); } else { diff --git a/frontend/src/components/context_menu.rs b/frontend/src/components/context_menu.rs index 03e74d3..3b86d11 100644 --- a/frontend/src/components/context_menu.rs +++ b/frontend/src/components/context_menu.rs @@ -12,8 +12,9 @@ pub fn ContextMenu( let hash = torrent_hash.clone(); let action_str = action.to_string(); - on_close.call(()); // Always close menu - on_action.call((action_str, hash)); // Delegate + logging::log!("ContextMenu: Action '{}' for hash '{}'", action_str, hash); + on_action.call((action_str, hash)); // Delegate FIRST + on_close.call(()); // Close menu AFTER }; if !visible { diff --git a/frontend/src/components/modal.rs b/frontend/src/components/modal.rs index 524b050..3ea3f0f 100644 --- a/frontend/src/components/modal.rs +++ b/frontend/src/components/modal.rs @@ -40,7 +40,10 @@ pub fn Modal( class=format!("flex-1 px-4 py-3 rounded-xl transition-all font-bold text-white shadow-lg {}", if is_danger { "bg-red-500 hover:bg-red-600 shadow-red-500/20" } else { "bg-blue-500 hover:bg-blue-600 shadow-blue-500/20" } ) - on:click=move |_| on_confirm.with_value(|cb| cb.call(())) + on:click=move |_| { + logging::log!("Modal: Confirm clicked"); + on_confirm.with_value(|cb| cb.call(())) + } > {confirm_text.get_value()}