diff --git a/crates/gpui/playground/ui/src/node.rs b/crates/gpui/playground/ui/src/node.rs index 36d85c09b2..ea1eb4bc1e 100644 --- a/crates/gpui/playground/ui/src/node.rs +++ b/crates/gpui/playground/ui/src/node.rs @@ -355,8 +355,8 @@ impl Node { dbg!(self.id_as_string()); for axis in [Axis2d::X, Axis2d::Y] { - dbg!(axis); let length = self.style.size.get(axis); + dbg!(axis, length); match length { Length::Fixed(fixed_length) => { @@ -364,7 +364,8 @@ impl Node { // before laying out the children. let fixed_length = fixed_length.to_pixels(rem_pixels); let mut remaining_flex = total_flex.get(axis); - let mut remaining_length = padded_constraint.max.get(axis) - fixed_length; + let mut remaining_length = + (padded_constraint.max.get(axis) - fixed_length).max(0.); // Here we avoid the padding exceeding the fixed length by giving // the padding calculation its own remaining_flex and remaining_length. @@ -379,7 +380,7 @@ impl Node { rem_pixels, ); remaining_flex -= padding_flex; - remaining_length -= padding_flex; + remaining_length -= padding_length; layout.margins.compute_flex_edges( &self.style.margins, axis, @@ -388,6 +389,8 @@ impl Node { rem_pixels, ); + dbg!(remaining_flex, remaining_length); + child_constraint.max.set(axis, remaining_length); if axis == cross_axis { child_constraint.min.set(axis, remaining_length);