Skip to content

Commit

Permalink
Don’t avoid floats for flex items.
Browse files Browse the repository at this point in the history
Fix #2292
  • Loading branch information
grewn0uille committed Nov 11, 2024
1 parent ca74c8e commit 0883acf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
27 changes: 27 additions & 0 deletions tests/layout/test_flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,3 +755,30 @@ def test_flex_auto_margin2():
outer, = body.children
inner, = outer.children
assert inner.margin_left != 0


@assert_no_logs
def test_flex_overflow():
# Regression test for https://github.com/Kozea/WeasyPrint/issues/2292
page, = render_pages('''
<style>
article {
display: flex;
}
section {
overflow: hidden;
width: 5px;
}
</style>
<article>
<section>A</section>
<section>B</section>
</article>
''')
html, = page.children
body, = html.children
article, = body.children
section_1 = article.children[0]
section_2 = article.children[1]
assert section_1.position_x == 0
assert section_2.position_x == 5
6 changes: 3 additions & 3 deletions weasyprint/layout/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ def block_box_layout(context, box, bottom_space, skip_stack,
result = block_container_layout(
context, box, bottom_space, skip_stack, page_is_empty,
absolute_boxes, fixed_boxes, adjoining_margins, discard, max_lines)
# TODO: columns shouldn't be block boxes, this condition would then be
# useless when this is fixed.
if not (new_box := result[0]) or new_box.is_column:
# TODO: columns and flex items shouldn't be block boxes, this condition
# would then be useless when this is fixed.
if not (new_box := result[0]) or new_box.is_column or new_box.is_flex_item:
return result
if new_box.is_table_wrapper or new_box.establishes_formatting_context():
# Don't collide with floats
Expand Down

0 comments on commit 0883acf

Please sign in to comment.