-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[0.71.0-rc.0] Gap, flexWrap & alignContent renders wrong size #35351
Comments
Good report (and good we can fix before much usage). Gap should not cause the height to increase when it is the reason for wrapping. Will take a look and add this as a test. FYI @jacobp100
|
Since |
Still happens with just Planning to dig in a bit, since I know running these UTs is currently a giant pain in OSS (I thought I would have added the CMake baed UTs a while back but have been awful about maintaining focus recently). But should be manually reproable as well. |
If you post the branch name I can dig a bit too |
Maybe it's worth adding a disclaimer about |
@intergalacticspacehighway FYI too |
This is actually something that I was talking about with @Titozzz: is there a way to maybe have the flex-gap stuff hidden behind some experimental flag so that folks know that fixes/issues/bugs and breaking changes might come at a later stage as things pop up? |
Debugging this, comparing wrap with gap vs wrap due to size overflow. Step 8: "MULTI-LINE CONTENT ALIGNMENT" is normally what sets things up. Children should most recently have been called with cross axis In the gap case, measured cross-axis dimensions are 300px at this step. In the non-gap case it is transiently this (I think it is the result of a different YGMeasureMode?). But it means at some previous step we are not measuring cross-axis correctly specifically in the gap case. |
I don't think we should gate it. There are more conformance tests we could maybe add to have caught this (e.g. a plan was to generate more Yoga fixtures from WPT), but real usage is also what led to bug discovery here, and putting the feature behind a flag would prevent that. I do want to gate future capabilities behind |
I think the issue could be on this statement where it doesn't account gap and |
Okay, so I think I'm understanding this? In If we do have overflow, then we set Probably worth checking the other usages of |
Yeah, it looks like I think the right solution here is to rename this, and incorporate gap spacing into its checks. |
Summary: In facebook/react-native#35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap. In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization? If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead. `flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`. We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap. Differential Revision: D41311424 fbshipit-source-id: 7d04bbe7bf09f0ca3481d3ff2a7c23b67f359b3e
PR here: facebook/yoga#1173 |
I also think we should not gate it, but warn users that if it doesn't match the spec there will be breaking changes might be a good idea |
A general strategy for compatibility fixes has been:
We are starting off at zero usage of gap within the RN ecosystem, so we are probably safe to make fixes while the usage is building, but after, we could fold likely impacting changes into StrictLayout. |
It's also one of the reasons I want to gate new major additions behind StrictLayout, since it makes that guarantee explicit (unless you opt into a quirk). |
Summary: X-link: facebook/yoga#1173 In facebook/react-native#35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap. In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization? If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead. `flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`. We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap. Changelog: [General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched Reviewed By: yungsters Differential Revision: D41311424 fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
Summary: Pull Request resolved: #1173 In facebook/react-native#35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap. In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization? If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead. `flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`. We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap. Changelog: [General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched Reviewed By: yungsters Differential Revision: D41311424 fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
Summary: X-link: facebook/yoga#1173 In #35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap. In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization? If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead. `flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`. We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap. Changelog: [General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched Reviewed By: yungsters Differential Revision: D41311424 fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
Fixed by 1aa157b |
Summary: X-link: facebook/yoga#1173 In #35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap. In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization? If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead. `flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`. We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap. Changelog: [General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched Reviewed By: yungsters Differential Revision: D41311424 fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
Summary: X-link: facebook/yoga#1173 In #35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap. In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization? If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead. `flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`. We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap. Changelog: [General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched Reviewed By: yungsters Differential Revision: D41311424 fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
Summary: X-link: facebook/yoga#1173 In facebook#35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap. In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization? If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead. `flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`. We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap. Changelog: [General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched Reviewed By: yungsters Differential Revision: D41311424 fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
Description
When using gap, flexWrap and alignContent, size is miscalculated, because gap isn't taken into account when computing the sizes, so if any wrapping happens because of gap, it is not computed properly
Please note that I have tried with and without legacyStretchBehavior enabled (by patching react-native).
Version
0.71.0-rc.0
Output of
npx react-native info
System:
OS: macOS 12.6
CPU: (8) arm64 Apple M1
Memory: 155.78 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.11.0 - /usr/local/bin/node
Yarn: 1.22.17 - /opt/homebrew/bin/yarn
npm: 8.19.2 - /usr/local/bin/npm
Watchman: 2022.10.10.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9123335
Xcode: 13.4/13F17a - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.0-rc.0 => 0.71.0-rc.0
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
In order to reproduce you need to have:
When that happens the size calculated by alignContent: ’stretch’ doesn’t take into account the wrap, so each child will have the full container size instead of half .
Example:
Before adding gap: 1
After adding gap: 1
Note that if the child where already wrapping (example width: 61) this would not happen. It only happens if the wrapping is caused by gap
Snack, code example, screenshot, or link to a repository
Web equivalent:
https://jsfiddle.net/t8q6xevj/1/
Native Code used to test:
Feel free to alter gap of container / width of children
The text was updated successfully, but these errors were encountered: