diff --git a/render-wasm/src/shapes/modifiers/grid_layout.rs b/render-wasm/src/shapes/modifiers/grid_layout.rs index 7ef2cb447b..3599f1e595 100644 --- a/render-wasm/src/shapes/modifiers/grid_layout.rs +++ b/render-wasm/src/shapes/modifiers/grid_layout.rs @@ -750,7 +750,8 @@ pub fn reflow_grid_layout( let mut new_width = child_bounds.width(); if child.is_layout_horizontal_fill() { let margin_left = child.layout_item.map(|i| i.margin_left).unwrap_or(0.0); - new_width = cell.width - margin_left; + let margin_right = child.layout_item.map(|i| i.margin_right).unwrap_or(0.0); + new_width = cell.width - margin_left - margin_right; let min_width = child.layout_item.and_then(|i| i.min_w).unwrap_or(MIN_SIZE); let max_width = child.layout_item.and_then(|i| i.max_w).unwrap_or(MAX_SIZE); new_width = new_width.clamp(min_width, max_width); @@ -759,7 +760,8 @@ pub fn reflow_grid_layout( let mut new_height = child_bounds.height(); if child.is_layout_vertical_fill() { let margin_top = child.layout_item.map(|i| i.margin_top).unwrap_or(0.0); - new_height = cell.height - margin_top; + let margin_bottom = child.layout_item.map(|i| i.margin_bottom).unwrap_or(0.0); + new_height = cell.height - margin_top - margin_bottom; let min_height = child.layout_item.and_then(|i| i.min_h).unwrap_or(MIN_SIZE); let max_height = child.layout_item.and_then(|i| i.max_h).unwrap_or(MAX_SIZE); new_height = new_height.clamp(min_height, max_height);