diff --git a/crates/ui/src/access.rs b/crates/ui/src/access.rs index c6f482543b90a0b79534e95ae402aa7e3c854c1a..4c9549bdd4443d258b7f3694e916ffc69b388f66 100644 --- a/crates/ui/src/access.rs +++ b/crates/ui/src/access.rs @@ -153,10 +153,13 @@ impl Ui { let mut nodes = Vec::new(); let mut children = Vec::new(); let mut seen = HashSet::from([Id::ROOT]); - self.describe(0, scale, None, &mut children, &mut nodes, &mut seen); let mut root = Node::new(Role::Window); root.set_label(label); - root.set_bounds(bounds(self.nodes[0].rect, scale)); + // Before the first frame is built, the window is all there is. + if let Some(built) = self.nodes.first() { + self.describe(0, scale, None, &mut children, &mut nodes, &mut seen); + root.set_bounds(bounds(built.rect, scale)); + } root.set_children(children.into_iter().map(|(id, _)| id).collect::>()); nodes.push((Id::ROOT, root)); let focus = self.focus.filter(|focus| seen.contains(focus));