Repository navigation
Conversation
Why === react#2105 added the min-content height walk that measures a leaf at its width, behind the experimental feature `MinContentHeightAtGivenWidth`, because it changes the arguments a host's measure function is called with. On react#2105, the maintainer asked for a follow-up that removes the flag. The enum value is in no release of Yoga. If this lands in the same React Native release as react#2105, that pull request's `[Added]` Changelog line for the feature should be left out of the release notes. Without the feature, a height is probed with at most zero and no limit on the width, so wrapped text in a column shrinks below its lines: ```html <div style="display: flex; flex-direction: column; width: 50px; height: 20px"> <div style="flex-shrink: 1">aaaa aaaa aaaa</div> <!-- three lines. Chrome: 30px. Yoga: 10px --> <div style="height: 10px; flex-shrink: 0"></div> </div> ``` How === The experimental feature is removed from `enums.py`, and the two places in `CalculateLayout.cpp` that read it now always take the feature's path. Layouts change only with `YGErrataMinSizeUndefinedInsteadOfAuto` off, since only then does Yoga find a min-content size. A host sees two changes. First, the arguments of a height probe: `YGMinContentMeasureFunc`, or the node's `YGMeasureFunc` when it has none, used to be called with an `Undefined` width and an `AtMost 0` height. It is now called with the node's content width as an `AtMost` width, or an `Undefined` width when neither the node nor a box above it gives it one (below a row, or in a column sized by its content), and always with an `Undefined` height. A measure function that recognizes a height probe by `AtMost 0`, or that answers it by clamping its height to zero, no longer does; a leaf whose min-content height is a constant can state it with `YGNodeSetMinContentHeight`. A width probe is unchanged: an `AtMost 0` width and an `Undefined` height. Second, a height result is keyed on the content width of the box around the leaf, so a clean leaf is measured again when that width changes, even if the leaf states its own width, and each box between the leaf and the flex item is walked again. A host that shares nodes between trees clones them for it. Yoga's `main` did this only with the feature on. The same walk resolves a percentage margin or padding below the item against the content width of the box around it instead of the flex container's, which changes `percent_margin_resolves_against_parent_content_width` without any measure function. `YGNode.h` documents the new arguments on `YGMinContentMeasureFunc`. No page of the website describes them. Test Plan ========= `python3 enums.py` removes the enum value from the C, C++, Java and JavaScript enum files, and `yarn gentest -f YGAutoMinSizeTest` regenerates the fixtures, which no longer set the feature; Chrome's values are unchanged. `cmake --build tests/build && tests/build/yogatests` passes, `node ./scripts/clang-format.js --check` passes, and `yarn gentest -h` leaves the tree clean. The generated Java and JavaScript tests were not run. With `CalculateLayout.cpp` reading the feature as off, which is `main` under a default set of experimental features, the 13 fixtures that used to set it fail. The height of the shrinking item: | Fixture | Chrome | Feature off | | --- | --- | --- | | `text_keeps_wrapped_lines` | 30 | 10 | | `nested_text_keeps_wrapped_lines` | 35 | 10 | | `text_wraps_inside_margin_and_padding` | 30 | 10 | | `text_wraps_at_stated_width` | 30 | 10 | | `text_wraps_at_stated_content_box_width` | 20 | 5 | | `text_wraps_inside_padded_parent` | 30 | 10 | | `percent_margin_resolves_against_parent_content_width` | 25 | 30 | | `text_fits_wider_parent` | 10 | 5 | | `text_fits_min_width` | 10 | 5 | | `text_wraps_at_max_width` | 30 | 10 | | `text_below_row_wraps_at_max_width` | 30 | 10 | | `text_below_row_is_not_wrapped` | 10 | 5 | | `text_in_wrapping_column_keeps_wrapped_lines` | 30 | 5 | `min_content_height_follows_given_width` and `min_content_height_without_owner_width_is_unconstrained` fail there too, both on the measure modes, and the first on heights of 16 where it expects 32 and 48. `min_content_height_probe_asks_for_at_most_zero` pinned the old arguments and is removed; `min_content_height_follows_given_width` asserts the new ones, and `nested_leaf_probed_at_most_once_per_axis_per_layout` now asserts the width of 0 that a width probe passes. No other test on `main` changes. Three more reach a height probe, `auto_min_includes_leaf_padding_height`, `nested_flexbox_recurses_into_min_content` and `issue_1651_measured_items_freeze_at_lower_bound`, and their measure functions return the same height for the old arguments and the new. React Native's `MinContentTest` cases (`packages/react-native/ReactCommon/yoga/test/BaselineTest.cpp`), built against this tree, pass except `testWalkClonesOnlyTheChildrenItWritesTo`. It lays out a column a second time at a narrower width and expects the walk to clone a child with percentage padding below an item that states its width. That padding now resolves against the item's width, which did not change, so the walk reads the child and leaves it shared. The test needs to move to a row, where the walk still passes the container's width down; that version passes against Yoga before and after this change. react/react-native#60452 makes that change. Changelog: [General][Changed] - Yoga probes a measured leaf's min-content height with its content width as an `AtMost` width and an `Undefined` height, instead of an `AtMost 0` height, so wrapped text in a column no longer shrinks below its lines when automatic minimum sizes are on
ide
force-pushed
the
@ide/remove-min-content-height-at-given-width
branch
from
December 2, 2026 01:28
a2bc636 to
dec7ed8
Compare
ide
marked this pull request as ready for review
December 2, 2026 01:52
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
#2105 added the min-content height walk that measures a leaf at its width, behind the experimental feature
MinContentHeightAtGivenWidth, because it changes the arguments a host's measure function is called with. On #2105, the maintainer asked for a follow-up that removes the flag. The enum value is in no release of Yoga. If this lands in the same React Native release as #2105, that pull request's[Added]Changelog line for the feature should be left out of the release notes.Without the feature, a height is probed with at most zero and no limit on the width, so wrapped text in a column shrinks below its lines:
How
The experimental feature is removed from
enums.py, and the two places inCalculateLayout.cppthat read it now always take the feature's path. Layouts change only withYGErrataMinSizeUndefinedInsteadOfAutooff, since only then does Yoga find a min-content size.A host sees two changes. First, the arguments of a height probe:
YGMinContentMeasureFunc, or the node'sYGMeasureFuncwhen it has none, used to be called with anUndefinedwidth and anAtMost 0height. It is now called with the node's content width as anAtMostwidth, or anUndefinedwidth when neither the node nor a box above it gives it one (below a row, or in a column sized by its content), and always with anUndefinedheight. A measure function that recognizes a height probe byAtMost 0, or that answers it by clamping its height to zero, no longer does; a leaf whose min-content height is a constant can state it withYGNodeSetMinContentHeight. A width probe is unchanged: anAtMost 0width and anUndefinedheight. Second, a height result is keyed on the content width of the box around the leaf, so a clean leaf is measured again when that width changes, even if the leaf states its own width, and each box between the leaf and the flex item is walked again. A host that shares nodes between trees clones them for it. Yoga'smaindid this only with the feature on.The same walk resolves a percentage margin or padding below the item against the content width of the box around it instead of the flex container's, which changes
percent_margin_resolves_against_parent_content_widthwithout any measure function.YGNode.hdocuments the new arguments onYGMinContentMeasureFunc. No page of the website describes them.Test Plan
python3 enums.pyremoves the enum value from the C, C++, Java and JavaScript enum files, andyarn gentest -f YGAutoMinSizeTestregenerates the fixtures, which no longer set the feature; Chrome's values are unchanged.cmake --build tests/build && tests/build/yogatestspasses,node ./scripts/clang-format.js --checkpasses, andyarn gentest -hleaves the tree clean. The generated Java and JavaScript tests were not run.With
CalculateLayout.cppreading the feature as off, which ismainunder a default set of experimental features, the 13 fixtures that used to set it fail. The height of the shrinking item:text_keeps_wrapped_linesnested_text_keeps_wrapped_linestext_wraps_inside_margin_and_paddingtext_wraps_at_stated_widthtext_wraps_at_stated_content_box_widthtext_wraps_inside_padded_parentpercent_margin_resolves_against_parent_content_widthtext_fits_wider_parenttext_fits_min_widthtext_wraps_at_max_widthtext_below_row_wraps_at_max_widthtext_below_row_is_not_wrappedtext_in_wrapping_column_keeps_wrapped_linesmin_content_height_follows_given_widthandmin_content_height_without_owner_width_is_unconstrainedfail there too, both on the measure modes, and the first on heights of 16 where it expects 32 and 48.min_content_height_probe_asks_for_at_most_zeropinned the old arguments and is removed;min_content_height_follows_given_widthasserts the new ones, andnested_leaf_probed_at_most_once_per_axis_per_layoutnow asserts the width of 0 that a width probe passes.No other test on
mainchanges. Three more reach a height probe,auto_min_includes_leaf_padding_height,nested_flexbox_recurses_into_min_contentandissue_1651_measured_items_freeze_at_lower_bound, and their measure functions return the same height for the old arguments and the new.React Native's
MinContentTestcases (packages/react-native/ReactCommon/yoga/test/BaselineTest.cpp), built against this tree, pass excepttestWalkClonesOnlyTheChildrenItWritesTo. It lays out a column a second time at a narrower width and expects the walk to clone a child with percentage padding below an item that states its width. That padding now resolves against the item's width, which did not change, so the walk reads the child and leaves it shared. The test needs to move to a row, where the walk still passes the container's width down; that version passes against Yoga before and after this change. react/react-native#60452 makes that change.Changelog:
[General][Changed] - Yoga probes a measured leaf's min-content height with its content width as an
AtMostwidth and anUndefinedheight, instead of anAtMost 0height, so wrapped text in a column no longer shrinks below its lines when automatic minimum sizes are on