From 111d7daa94fb0bd7af8b9bcb3c03cbab94379bfa Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 28 May 2026 12:13:02 +0200 Subject: [PATCH] :bug: Fix problem with absolute elements in flex layout --- .../src/shapes/modifiers/flex_layout.rs | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/render-wasm/src/shapes/modifiers/flex_layout.rs b/render-wasm/src/shapes/modifiers/flex_layout.rs index 41d3e02687..d51d6cb36d 100644 --- a/render-wasm/src/shapes/modifiers/flex_layout.rs +++ b/render-wasm/src/shapes/modifiers/flex_layout.rs @@ -3,8 +3,8 @@ use crate::error::{Error, Result}; use crate::math::{self as math, Bounds, Matrix, Point, Vector, VectorExt}; use crate::shapes::{ - AlignContent, AlignItems, AlignSelf, FlexData, JustifyContent, LayoutData, LayoutItem, - Modifier, Shape, + AlignContent, AlignItems, AlignSelf, ConstraintH, ConstraintV, FlexData, JustifyContent, + LayoutData, LayoutItem, Modifier, Shape, }; use crate::state::ShapesPoolRef; use crate::uuid::Uuid; @@ -749,6 +749,34 @@ pub fn reflow_flex_layout( scale.pre_concat(parent_transform_inv); let layout_bounds_after = layout_bounds.transform(&scale); + + // Propagate the parent auto-resize to absolute children using their constraints. + for child_id in shape.children_ids_iter(true) { + let Some(child) = shapes.get(child_id) else { + continue; + }; + + if !child.is_absolute() { + continue; + } + + let child_bounds = bounds.find(child); + let constraint_h = child.constraint_h(ConstraintH::Left); + let constraint_v = child.constraint_v(ConstraintV::Top); + + let child_transform = super::constraints::propagate_shape_constraints( + layout_bounds, + &layout_bounds_after, + &child_bounds, + constraint_h, + constraint_v, + scale, + child.ignore_constraints, + )?; + + result.push_back(Modifier::transform_propagate(child.id, child_transform)); + } + result.push_back(Modifier::parent(shape.id, scale)); bounds.insert(shape.id, layout_bounds_after); }