Files
yoga/gentest/fixtures/YGFlexWrapTest.html
Nick Gerleman 464d1668ba Fix sizing and alignment issues with multi-line containers (#1513)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1513

X-link: https://github.com/facebook/react-native/pull/41916

Fixes https://github.com/facebook/yoga/issues/1300
Fixes https://github.com/facebook/yoga/issues/1008

This fixes a smattering of issues related to both sizing and aligment of multi-line-containers:

1. We were previously incorrectly bounding the size of each flex line to the min/max of the entire container.
2. Per-line leads were sometimes incorrectly contributing to alignment within the line
3. The cross dim size used for multi-line alignment is not correct, or correctly clamped. If the available size comes from a max constraint, that was incorrectly used instead of a definite size, or size of content. Leads were entirely skipped for min constraint.

Need to test how breaking this is, to see if it might need to go behind an errata.

See related PRs:
1. https://github.com/facebook/yoga/pull/1491
2. https://github.com/facebook/yoga/pull/1493
3. https://github.com/facebook/yoga/pull/1013

Changelog:
[General][Fixed] - Fix Yoga sizing and alignment issues with multi-line containers

Reviewed By: joevilches

Differential Revision: D52087013

fbshipit-source-id: 8d95ad17e58c1fec1cceab9756413d0b3bd4cd8f
2023-12-16 01:12:30 -08:00

168 lines
7.4 KiB
HTML

<div id="wrap_column" style="height: 100px; flex-wrap: wrap">
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row" style="width: 100px; flex-direction: row; flex-wrap: wrap">
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row_align_items_flex_end" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: flex-end;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row_align_items_center" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: center;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="flex_wrap_children_with_min_main_overriding_flex_basis" style="width: 100px; flex-wrap: wrap; flex-direction: row;">
<div style="flex-basis: 50px; height: 50px; min-width: 55px;"></div>
<div style="flex-basis: 50px; height: 50px; min-width: 55px;"></div>
</div>
<div id="flex_wrap_wrap_to_child_height">
<div style="flex-direction: row; align-items: flex-start; flex-wrap: wrap;">
<div style="width: 100px;">
<div style="height: 100px; width: 100px;"></div>
</div>
</div>
<div style="width: 100px; height: 100px;"></div>
</div>
<div id="flex_wrap_align_stretch_fits_one_row" style="width: 150px; height: 100px; flex-wrap: wrap; flex-direction: row;">
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
</div>
<div id="wrap_reverse_row_align_content_flex_start" style="width: 100px; flex-direction: row; flex-wrap: wrap-reverse; align-content: flex-start;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 40px; width: 30px;"></div>
<div style="height: 50px; width: 30px;"></div>
</div>
<div id="wrap_reverse_row_align_content_center" style="width: 100px; flex-direction: row; flex-wrap: wrap-reverse; align-content: center;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 40px; width: 30px;"></div>
<div style="height: 50px; width: 30px;"></div>
</div>
<div id="wrap_reverse_row_single_line_different_size" style="width: 300px; flex-direction: row; flex-wrap: wrap-reverse; align-content: flex-start;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 40px; width: 30px;"></div>
<div style="height: 50px; width: 30px;"></div>
</div>
<div id="wrap_reverse_row_align_content_stretch" style="width: 100px; flex-direction: row; flex-wrap: wrap-reverse; align-content: stretch;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 40px; width: 30px;"></div>
<div style="height: 50px; width: 30px;"></div>
</div>
<div id="wrap_reverse_row_align_content_space_around" style="width: 100px; flex-direction: row; flex-wrap: wrap-reverse; align-content: space-around;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 40px; width: 30px;"></div>
<div style="height: 50px; width: 30px;"></div>
</div>
<div id="wrap_reverse_column_fixed_size" style="width: 200px; height: 100px; flex-direction: column; flex-wrap: wrap-reverse; align-items: center;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 40px; width: 30px;"></div>
<div style="height: 50px; width: 30px;"></div>
</div>
<div id="wrapped_row_within_align_items_center" style="width: 200px; height: 200px; align-items: center;">
<div style="flex-direction:row; flex-wrap: wrap;">
<div style="width: 150px; height: 80px;"></div>
<div style="width: 80px; height: 80px;"></div>
</div>
</div>
<div id="wrapped_row_within_align_items_flex_start" style="width: 200px; height: 200px; align-items: flex-start;">
<div style="flex-direction:row; flex-wrap: wrap;">
<div style="width: 150px; height: 80px;"></div>
<div style="width: 80px; height: 80px;"></div>
</div>
</div>
<div id="wrapped_row_within_align_items_flex_end" style="width: 200px; height: 200px; align-items: flex-end;">
<div style="flex-direction:row; flex-wrap: wrap;">
<div style="width: 150px; height: 80px;"></div>
<div style="width: 80px; height: 80px;"></div>
</div>
</div>
<div id="wrapped_column_max_height" style="height: 500px; width: 700px; flex-direction: column;align-items: center; justify-content: center; align-content: center; flex-wrap:wrap;">
<div style="width: 100px; height: 500px; max-height: 200px;"></div>
<div style="width: 200px; height: 200px; margin: 20px;"></div>
<div style="width: 100px; height: 100px;"></div>
</div>
<div id="wrapped_column_max_height_flex" style="height: 500px; width: 700px; flex-direction: column;align-items: center; justify-content: center; align-content: center; flex-wrap:wrap;">
<div style="width: 100px; height: 500px; max-height: 200px; flex: 1;"></div>
<div style="width: 200px; height: 200px; margin: 20px; flex: 1"></div>
<div style="width: 100px; height: 100px;"></div>
</div>
<div id="wrap_nodes_with_content_sizing_overflowing_margin" style="width: 500px; height: 500px;">
<div style="flex-direction: row; flex-wrap: wrap; width: 85px;">
<div>
<div style="height: 40px; width: 40px;"></div>
</div>
<div style="margin-right: 10px;">
<div style="height: 40px; width: 40px;"></div>
</div>
</div>
</div>
<div id="wrap_nodes_with_content_sizing_margin_cross" style="width: 500px; height: 500px;">
<div style="flex-direction: row; flex-wrap: wrap; width: 70px;">
<div>
<div style="height: 40px; width: 40px;"></div>
</div>
<div style="margin-top: 10px;">
<div style="height: 40px; width: 40px;"></div>
</div>
</div>
</div>
<div id="wrap_with_min_cross_axis" style="width: 500px; min-height: 500px; flex-direction: row; flex-wrap: wrap;">
<div style="width: 400px; height: 200px;"></div>
<div style="width: 400px; height: 200px;"></div>
</div>
<div id="wrap_with_max_cross_axis" style="width: 500px; max-height: 500px; flex-direction: row; flex-wrap: wrap;">
<div style="width: 400px; height: 200px;"></div>
<div style="width: 400px; height: 200px;"></div>
</div>
<div id="nowrap_expands_flexline_box_to_min_cross" style="min-height: 400px; flex-direction: row; align-items: stretch; align-content: flex-start;">
<div style="flex: 1"></div>
</div>
<div id="wrap_does_not_impose_min_cross_onto_single_flexline" style="min-height: 400px; flex-direction: row; align-items: stretch; align-content: flex-start; flex-wrap: wrap;">
<div style="flex: 1"></div>
</div>