Use group overlay for containers w/ children

This commit is contained in:
Cory Forsstrom 2023-01-17 10:12:51 -08:00
parent 3c866c15aa
commit b2a3a85acb
No known key found for this signature in database
GPG key ID: 1DFE170A4415C9F5
2 changed files with 13 additions and 8 deletions

View file

@ -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::<Vec<_>>();
(!children.is_empty()).then(|| Group::with_children(children).overlay())
}