Skip to content

Commit

Permalink
Merge pull request #2300 from Kozea/fix_2292
Browse files Browse the repository at this point in the history
Don’t avoid floats for flex items
  • Loading branch information
grewn0uille authored Nov 11, 2024
2 parents ca74c8e + 0883acf commit 43f5dfa
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 43f5dfa

Please sign in to comment.