From 8aa28483e13a218f495df26609c891eda8e8752f Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Tue, 4 Feb 2025 16:40:06 +0100 Subject: [PATCH] Handle auto flex item width in columns --- weasyprint/layout/flex.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/weasyprint/layout/flex.py b/weasyprint/layout/flex.py index a6c68e7e5..3410390e3 100644 --- a/weasyprint/layout/flex.py +++ b/weasyprint/layout/flex.py @@ -596,9 +596,14 @@ def flex_layout(context, box, bottom_space, skip_stack, containing_block, # to the child bottom margin. child.margin_bottom += block.collapse_margin(adjoining_margins) else: - # TODO: We had min_content_width here but I have no idea under - # what circumstance that would be correct. - child.width = new_child.width + if child.width == 'auto': + child.width = min( + max( + min_content_width(context, child, outer=False), + new_child.width), + max_content_width(context, box, outer=False)) + else: + child.width = new_child.width new_flex_line.append((index, child))