From b2a3a85acb2a0722e90c46b70d574f1d676da9d1 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Tue, 17 Jan 2023 10:12:51 -0800 Subject: Use group overlay for containers w/ children --- native/src/overlay.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'native/src/overlay.rs') diff --git a/native/src/overlay.rs b/native/src/overlay.rs index 0b1e8daf..e7394494 100644 --- a/native/src/overlay.rs +++ b/native/src/overlay.rs @@ -91,7 +91,7 @@ where } } -/// Obtains the first overlay [`Element`] found in the given children. +/// Returns a [`Group`] of overlay [`Element`] children. /// /// This method will generally only be used by advanced users that are /// implementing the [`Widget`](crate::Widget) trait. @@ -104,12 +104,14 @@ pub fn from_children<'a, Message, Renderer>( where Renderer: crate::Renderer, { - children + let children = children .iter_mut() .zip(&mut tree.children) .zip(layout.children()) .filter_map(|((child, state), layout)| { child.as_widget_mut().overlay(state, layout, renderer) }) - .next() + .collect::>(); + + (!children.is_empty()).then(|| Group::with_children(children).overlay()) } -- cgit