Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don’t avoid floats for flex items #2300

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading