From b87e2e8979b13067f496f26c6471f6611ea7e5c2 Mon Sep 17 00:00:00 2001 From: luoxiaozero <48741584+luoxiaozero@users.noreply.github.com> Date: Wed, 10 Apr 2024 22:45:01 +0800 Subject: [PATCH] Fix/240410 (#162) * pref: unused variable warning * fix: teleport hydrate error * style: leptosfmt --- thaw/src/drawer/mod.rs | 4 ++-- thaw/src/layout/mod.rs | 1 + thaw/src/modal/mod.rs | 10 ++++++++-- thaw/src/scrollbar/mod.rs | 2 ++ thaw_components/src/focus_trap/mod.rs | 13 ++++++++++--- thaw_components/src/teleport/mod.rs | 14 ++------------ 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/thaw/src/drawer/mod.rs b/thaw/src/drawer/mod.rs index cca2b93..aa872bf 100644 --- a/thaw/src/drawer/mod.rs +++ b/thaw/src/drawer/mod.rs @@ -113,8 +113,8 @@ pub fn Drawer( >
+ {children()}
diff --git a/thaw/src/modal/mod.rs b/thaw/src/modal/mod.rs index 4d94be2..396ad7d 100644 --- a/thaw/src/modal/mod.rs +++ b/thaw/src/modal/mod.rs @@ -64,7 +64,7 @@ pub fn Modal( }); view! { - +
{children()} diff --git a/thaw_components/src/focus_trap/mod.rs b/thaw_components/src/focus_trap/mod.rs index 7bc8b56..4dfab3a 100644 --- a/thaw_components/src/focus_trap/mod.rs +++ b/thaw_components/src/focus_trap/mod.rs @@ -1,9 +1,8 @@ -use leptos::{leptos_dom::helpers::WindowListenerHandle, *}; -use std::cell::RefCell; +use leptos::*; #[cfg(any(feature = "csr", feature = "hydrate"))] thread_local! { - static STACK: RefCell> = Default::default(); + static STACK: std::cell::RefCell> = Default::default(); } #[component] @@ -15,6 +14,7 @@ pub fn FocusTrap( ) -> impl IntoView { #[cfg(any(feature = "csr", feature = "hydrate"))] if disabled == false { + use leptos::leptos_dom::helpers::WindowListenerHandle; let esc_handle = StoredValue::new(None::); let id = StoredValue::new(uuid::Uuid::new_v4()); @@ -55,5 +55,12 @@ pub fn FocusTrap( }); } + #[cfg(not(any(feature = "csr", feature = "hydrate")))] + { + let _ = disabled; + let _ = active; + let _ = on_esc; + } + children() } diff --git a/thaw_components/src/teleport/mod.rs b/thaw_components/src/teleport/mod.rs index afd547c..5c2b653 100644 --- a/thaw_components/src/teleport/mod.rs +++ b/thaw_components/src/teleport/mod.rs @@ -60,17 +60,7 @@ pub fn Teleport( } else { let _ = mount; let _ = immediate; - #[cfg(not(feature = "ssr"))] - { - let _ = element; - let _ = children; - } - #[cfg(feature = "ssr")] - if element.is_none() { - if let Some(children) = children { - // Consumed hydration `id` - let _ = children(); - } - } + let _ = element; + let _ = children; }} }