From 898bfa859015e9809dcf8c04317d172ceec9bd09 Mon Sep 17 00:00:00 2001 From: "rust-for-web[bot]" <191031261+rust-for-web[bot]@users.noreply.github.com> Date: Thu, 12 Mar 2026 09:33:34 +0000 Subject: [PATCH 1/2] feat: update to upstream @floating-ui/dom@1.7.6 --- upstream.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstream.toml b/upstream.toml index a40c653..90dd46f 100644 --- a/upstream.toml +++ b/upstream.toml @@ -1,5 +1,5 @@ [releases] core = "1.7.5" -dom = "1.7.4" +dom = "1.7.6" utils = "0.2.11" vue = "1.1.9" From a77ab4b298d81bf0a6d5ec4da1fb261a6f831dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABlle=20Huisman?= Date: Thu, 12 Mar 2026 11:37:07 +0100 Subject: [PATCH 2/2] feat(dom): allow not passing a floating element to `auto_update` --- packages/dioxus/src/use_auto_update.rs | 9 +++-- packages/dom/src/auto_update.rs | 32 ++++++++++------- .../dom/src/platform/get_clipping_rect.rs | 34 +++++++++---------- packages/leptos/src/types.rs | 18 +++++++--- .../tests/visual/src/spec/auto_update.rs | 2 +- packages/yew/src/use_auto_update.rs | 10 ++++-- 6 files changed, 66 insertions(+), 39 deletions(-) diff --git a/packages/dioxus/src/use_auto_update.rs b/packages/dioxus/src/use_auto_update.rs index 5588275..270a36d 100644 --- a/packages/dioxus/src/use_auto_update.rs +++ b/packages/dioxus/src/use_auto_update.rs @@ -11,7 +11,12 @@ use crate::{ShallowRc, types::WhileElementsMountedFn}; pub fn use_auto_update() -> Memo> { use_memo(|| { let rc: Rc = Rc::new(|reference, floating, update| { - auto_update(reference, floating, update, AutoUpdateOptions::default()) + auto_update( + reference, + Some(floating), + update, + AutoUpdateOptions::default(), + ) }); rc.into() @@ -28,7 +33,7 @@ pub fn use_auto_update_with_options( let options = options(); let rc: Rc = Rc::new(move |reference, floating, update| { - auto_update(reference, floating, update, options.clone()) + auto_update(reference, Some(floating), update, options.clone()) }); rc.into() diff --git a/packages/dom/src/auto_update.rs b/packages/dom/src/auto_update.rs index a8d3347..ccefd3d 100644 --- a/packages/dom/src/auto_update.rs +++ b/packages/dom/src/auto_update.rs @@ -254,7 +254,7 @@ impl AutoUpdateOptions { /// Should only be called when the floating element is mounted on the DOM or visible on the screen. pub fn auto_update( reference: ElementOrVirtual, - floating: &Element, + floating: Option<&Element>, update: Rc, options: AutoUpdateOptions, ) -> Box { @@ -278,7 +278,9 @@ pub fn auto_update( ancestors = get_overflow_ancestors(reference, ancestors, true); } - ancestors.append(&mut get_overflow_ancestors(floating, vec![], true)); + if let Some(floating) = floating { + ancestors.append(&mut get_overflow_ancestors(floating, vec![], true)); + } ancestors } else { @@ -327,16 +329,18 @@ pub fn auto_update( let resize_observer: Rc>> = Rc::new(RefCell::new(None)); if element_resize { - let reobserve_floating = floating.clone(); let reobserve_closure: Rc> = Rc::new(Closure::new({ + let floating = floating.cloned(); let resize_observer = resize_observer.clone(); move || { - resize_observer - .borrow() - .as_ref() - .expect("Resize observer should exist.") - .observe(&reobserve_floating); + if let Some(floating) = floating.as_ref() { + resize_observer + .borrow() + .as_ref() + .expect("Resize observer should exist.") + .observe(floating); + } } })); @@ -378,11 +382,13 @@ pub fn auto_update( .observe(reference); } - resize_observer - .borrow() - .as_ref() - .expect("Resize observer should exist.") - .observe(floating); + if let Some(floating) = floating { + resize_observer + .borrow() + .as_ref() + .expect("Resize observer should exist.") + .observe(floating); + } } let frame_id: Rc>> = Rc::new(RefCell::new(None)); diff --git a/packages/dom/src/platform/get_clipping_rect.rs b/packages/dom/src/platform/get_clipping_rect.rs index bfae240..c4625ac 100644 --- a/packages/dom/src/platform/get_clipping_rect.rs +++ b/packages/dom/src/platform/get_clipping_rect.rs @@ -193,25 +193,25 @@ pub fn get_clipping_rect( .chain(vec![ElementOrRootBoundary::RootBoundary(root_boundary)]) .collect(); - let init = + let first_rect = get_client_rect_from_clipping_ancestor(element, clipping_ancestors[0].clone(), strategy); - let clipping_rect = clipping_ancestors - .into_iter() - .fold(init, |mut acc, clipping_ancestor| { - let rect = get_client_rect_from_clipping_ancestor(element, clipping_ancestor, strategy); - - acc.top = acc.top.max(rect.top); - acc.right = acc.right.min(rect.right); - acc.bottom = acc.bottom.min(rect.bottom); - acc.left = acc.left.max(rect.left); - - acc - }); + let mut top = first_rect.top; + let mut right = first_rect.right; + let mut bottom = first_rect.bottom; + let mut left = first_rect.left; + + for clipping_ancestor in clipping_ancestors.into_iter().skip(1) { + let rect = get_client_rect_from_clipping_ancestor(element, clipping_ancestor, strategy); + top = top.max(rect.top); + right = right.min(rect.right); + bottom = bottom.min(rect.bottom); + left = left.max(rect.left); + } Rect { - x: clipping_rect.left, - y: clipping_rect.top, - width: clipping_rect.right - clipping_rect.left, - height: clipping_rect.bottom - clipping_rect.top, + x: left, + y: top, + width: right - left, + height: bottom - top, } } diff --git a/packages/leptos/src/types.rs b/packages/leptos/src/types.rs index e09e945..667fa37 100644 --- a/packages/leptos/src/types.rs +++ b/packages/leptos/src/types.rs @@ -93,7 +93,12 @@ impl UseFloatingOptions { pub fn while_elements_mounted_auto_update(self) -> Self { let auto_update_rc: SendWrapper> = SendWrapper::new(Rc::new(|reference, floating, update| { - auto_update(reference, floating, update, AutoUpdateOptions::default()) + auto_update( + reference, + Some(floating), + update, + AutoUpdateOptions::default(), + ) })); self.while_elements_mounted(auto_update_rc) } @@ -102,7 +107,12 @@ impl UseFloatingOptions { pub fn while_elements_mounted_auto_update_with_enabled(self, enabled: Signal) -> Self { let auto_update_rc: SendWrapper> = SendWrapper::new(Rc::new(|reference, floating, update| { - auto_update(reference, floating, update, AutoUpdateOptions::default()) + auto_update( + reference, + Some(floating), + update, + AutoUpdateOptions::default(), + ) })); self.while_elements_mounted(MaybeProp::derive(move || { if enabled.get() { @@ -121,7 +131,7 @@ impl UseFloatingOptions { let auto_update_rc = move |options: AutoUpdateOptions| -> SendWrapper> { SendWrapper::new(Rc::new(move |reference, floating, update| { - auto_update(reference, floating, update, options.clone()) + auto_update(reference, Some(floating), update, options.clone()) })) }; @@ -139,7 +149,7 @@ impl UseFloatingOptions { let auto_update_rc = move |options: AutoUpdateOptions| -> SendWrapper> { SendWrapper::new(Rc::new(move |reference, floating, update| { - auto_update(reference, floating, update, options.clone()) + auto_update(reference, Some(floating), update, options.clone()) })) }; diff --git a/packages/leptos/tests/visual/src/spec/auto_update.rs b/packages/leptos/tests/visual/src/spec/auto_update.rs index 4e5915c..f057757 100644 --- a/packages/leptos/tests/visual/src/spec/auto_update.rs +++ b/packages/leptos/tests/visual/src/spec/auto_update.rs @@ -93,7 +93,7 @@ pub fn AutoUpdate() -> impl IntoView { cleanup.set_value(Some(SendWrapper::new(auto_update( (&reference).into(), - &floating, + Some(&floating), (*update).clone(), options .get() diff --git a/packages/yew/src/use_auto_update.rs b/packages/yew/src/use_auto_update.rs index 538a6f0..88d9e0b 100644 --- a/packages/yew/src/use_auto_update.rs +++ b/packages/yew/src/use_auto_update.rs @@ -12,7 +12,13 @@ use crate::types::WhileElementsMountedFn; pub fn use_auto_update() -> Rc> { use_memo((), |_| { let rc: Rc = Rc::new(|reference, floating, update| { - auto_update(reference, floating, update, AutoUpdateOptions::default()).into() + auto_update( + reference, + Some(floating), + update, + AutoUpdateOptions::default(), + ) + .into() }); rc @@ -28,7 +34,7 @@ pub fn use_auto_update_with_options(options: AutoUpdateOptions) -> Rc = Rc::new(move |reference, floating, update| { - auto_update(reference, floating, update, options.clone()).into() + auto_update(reference, Some(floating), update, options.clone()).into() }); rc