From 19d9d7f30f53003bcb4b373e23e758ea6eaa3f31 Mon Sep 17 00:00:00 2001 From: spinline Date: Fri, 6 Feb 2026 13:34:07 +0300 Subject: [PATCH] fix: use details-based dropdowns for iOS Safari toggle behavior --- frontend/src/components/layout/statusbar.rs | 94 ++++++++++++--------- 1 file changed, 52 insertions(+), 42 deletions(-) diff --git a/frontend/src/components/layout/statusbar.rs b/frontend/src/components/layout/statusbar.rs index 9dc5914..7f2c7c1 100644 --- a/frontend/src/components/layout/statusbar.rs +++ b/frontend/src/components/layout/statusbar.rs @@ -110,9 +110,21 @@ pub fn StatusBar() -> impl IntoView { }); }; - // Helper to close dropdowns by blurring the active element + // Helper to close all details dropdowns let close_dropdown = move || { if let Some(doc) = web_sys::window().and_then(|w| w.document()) { + // Close all
elements in the status bar + let details_list = doc.query_selector_all("details.dropdown[open]"); + if let Ok(nodes) = details_list { + for i in 0..nodes.length() { + if let Some(node) = nodes.item(i) { + if let Ok(el) = node.dyn_into::() { + el.remove_attribute("open").ok(); + } + } + } + } + // Also blur active element as fallback if let Some(active) = doc.active_element() { let _ = active .dyn_into::() @@ -120,15 +132,25 @@ pub fn StatusBar() -> impl IntoView { } } }; + + // Toggle dropdown: close all, the
native toggle handles opening + let toggle_dropdown = move |_id: u8| { + // No-op:
handles its own open/close natively + // We just need this for the close_dropdown helper + }; - // Global listener to force blur on touchstart (for iOS "tap outside" closing) + // Global listener to close dropdowns on touchstart outside let force_blur = move |_| { if let Some(doc) = web_sys::window().and_then(|w| w.document()) { - if let Some(active) = doc.active_element() { - // If something is focused, blur it to close dropdowns - let _ = active - .dyn_into::() - .map(|el| el.blur()); + let details_list = doc.query_selector_all("details.dropdown[open]"); + if let Ok(nodes) = details_list { + for i in 0..nodes.length() { + if let Some(node) = nodes.item(i) { + if let Ok(el) = node.dyn_into::() { + el.remove_attribute("open").ok(); + } + } + } } } }; @@ -138,15 +160,14 @@ pub fn StatusBar() -> impl IntoView {
// --- DOWNLOAD SPEED DROPDOWN --- - +
// --- UPLOAD SPEED DROPDOWN --- - +
- +