Skip to content

Commit

Permalink
Fix sizing and alignment issues with multi-line containers (facebook#…
Browse files Browse the repository at this point in the history
…1513)

Summary:

X-link: facebook/react-native#41916

Fixes facebook#1300
Fixes facebook#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. facebook#1491
2. facebook#1493
3. facebook#1013

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

Differential Revision: D52087013
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Dec 12, 2023
1 parent 738d04f commit ef24126
Show file tree
Hide file tree
Showing 12 changed files with 2,533 additions and 69 deletions.
55 changes: 54 additions & 1 deletion gentest/fixtures/YGAlignContentTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,57 @@
<div style="width:100px; height: 100px; align-items: center; flex-direction: row; align-content:stretch;">
<div style="height: 10px; width: 10px; align-content:stretch;"></div>
</div>
</div>
</div>

<div id="align_content_stretch_with_min_cross_axis" style="width: 500px; min-height: 500px; flex-direction: row; flex-wrap: wrap; align-content: stretch;">
<div style="width: 400px; height: 200px;"></div>
<div style="width: 400px; height: 200px;"></div>
</div>

<div id="align_content_stretch_with_max_cross_axis" style="width: 500px; max-height: 500px; flex-direction: row; flex-wrap: wrap; align-content: stretch;">
<div style="width: 400px; height: 200px;"></div>
<div style="width: 400px; height: 200px;"></div>
</div>

<div id="align_content_stretch_with_max_cross_axis_and_border_padding" style="width: 500px; max-height: 500px; flex-direction: row; flex-wrap: wrap; align-content: stretch; border: solid black 5px; padding: 2px">
<div style="width: 400px; height: 200px;"></div>
<div style="width: 400px; height: 200px;"></div>
</div>

<div id="align_content_space_evenly_with_min_cross_axis" style="width: 500px; min-height: 500px; flex-direction: row; flex-wrap: wrap; align-content: space-evenly;">
<div style="width: 400px; height: 200px;"></div>
<div style="width: 400px; height: 200px;"></div>
</div>

<div id="align_content_space_evenly_with_max_cross_axis" style="width: 500px; max-height: 500px; flex-direction: row; flex-wrap: wrap; align-content: space-evenly;">
<div style="width: 400px; height: 200px;"></div>
<div style="width: 400px; height: 200px;"></div>
</div>

<div id="align_content_space_evenly_with_max_cross_axis_violated" style="width: 500px; max-height: 300px; flex-direction: row; flex-wrap: wrap; align-content: space-evenly;">
<div style="width: 400px; height: 200px;"></div>
<div style="width: 400px; height: 200px;"></div>
</div>

<div id="align_content_space_evenly_with_max_cross_axis_violated_padding_and_border" style="width: 500px; max-height: 300px; flex-direction: row; flex-wrap: wrap; align-content: space-evenly; border: solid black 5px; padding: 2px">
<div style="width: 400px; height: 200px;"></div>
<div style="width: 400px; height: 200px;"></div>
</div>

<div id="align_content_space_around_and_align_items_flex_end_with_flex_wrap" style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: space-around;align-items: flex-end;">
<div style="height: 50px; width: 150px;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>

<div id="align_content_space_around_and_align_items_center_with_flex_wrap" style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: space-around;align-items: center;">
<div style="height: 50px; width: 150px;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>

<div id="align_content_space_around_and_align_items_flex_start_with_flex_wrap" style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: space-around;align-items: flex-start;">
<div style="height: 50px; width: 150px;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>
10 changes: 10 additions & 0 deletions gentest/fixtures/YGFlexWrapTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,13 @@
</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>
1 change: 0 additions & 1 deletion java/tests/com/facebook/yoga/YGAbsolutePositionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,6 @@ public void test_percent_absolute_position_infinite_height() {
}

@Test
@Ignore
public void test_absolute_layout_percentage_height_based_on_padded_parent() {
YogaConfig config = YogaConfigFactory.create();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
Expand Down
Loading

0 comments on commit ef24126

Please sign in to comment.