Fix fixFlexBasisFitContent causing layout collapse on re-layout #1964
Fix fixFlexBasisFitContent causing layout collapse on re-layout #1964scorsin-oai wants to merge 1 commit into
Conversation
An explicit flex-basis: 0 on an auto-sized, non-growing item should not make Yoga skip intrinsic measurement. Before this change, computeFlexBasisForChild only ignored the resolved zero basis while the owner main-axis size was indefinite. If a later pass had a definite owner main-axis size, the same node started using the resolved zero flex basis, so its main size could flip from content-sized to zero without a style change. That made layout depend on the shape of the previous layout pass. A measured label or a wrapper around measured content could be validly measured on the first pass, then collapse after the measured leaf was dirtied and the owner was laid out with a definite width or height. Runtime viewport and view-inflation layers can then treat visible descendants as outside a zero-sized ancestor. When FixFlexBasisFitContent is enabled, make explicit zero flex-basis deterministic for auto-sized, non-growing items by keeping them on the measurement path in both row and column directions. This applies to measured leaves, wrapper containers, 0%, padded containers, nested wrappers, and web-default shrink. Growing flex items still use zero basis for normal flex distribution, and items with an explicit main-axis size continue to let flex-basis win. Add focused tests for the original two-pass collapse in both axes and for related tree shapes that would otherwise hit the same root cause: direct measured children, first-definite layouts, percent zero basis, padding, nested wrappers, and web-default shrink. Add guardrails for flex-growing zero-basis items and explicit main-axis size behavior.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @scorsin-oai! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
This change fixes an issue where nodes could collapse to 0 on re-layout when fixFlexBasisFitContent is enabled.
This is the setup:
Repro sequence:
Yoga measured an auto-sized flex-basis: 0 item when the parent’s main-axis size was indefinite, so it got its intrinsic content size. On a later layout pass with a definite parent size, Yoga treated the resolved 0 basis as authoritative, skipped measurement, and collapsed the same item to 0.
What the fix does:
For FixFlexBasisFitContent, explicit flex-basis: 0 on an auto-sized, non-growing item stays on the measurement path, so its size is based on content consistently across layout passes. Flex-growing zero-basis items still use zero basis for normal flex distribution.