-
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.3] Redundant margin when using either rowGap or gap #35553
Comments
I can try to reproduce soon. cc @jacobp100 @intergalacticspacehighway in case either of you can get to it first. This one is kind of surprising to me given the test coverage. |
@NickGerleman let me know if you need more details on this from me (reproducing this issue should be pretty straightforward) |
I guess a test we miss is this: <div id="column_gap_inflexible" style="flex-direction: row; column-gap: 10px;">
<div><div style="width: 20px; height: 20px;"></div></div>
<div><div style="width: 20px; height: 20px;"></div></div>
<div><div style="width: 20px; height: 20px;"></div></div>
</div> Where the direct children have to resolve their children to calculate their size I also wonder if this bug still produces if you remove the extra <View
style={{
gap: 16,
backgroundColor: 'red',
}}
>
<Text style={{ backgroundColor: 'yellow' }}>test1</Text>
<Text style={{ backgroundColor: 'yellow' }}>test2</Text>
<Text style={{ backgroundColor: 'yellow' }}>test3</Text>
</View> @mobily ? |
Adding below check might fix it. Issue is that it's increasing the main axis size of the view. I think we should check for the last child here. We can check if it's the last child by So it's like before it was calculating Looking if it needs to be fixed somewhere else. |
@jacobp100 here's the screenshot after removing extra |
const bool isLastChild = i == collectedFlexItemsValues.endOfLineIndex - 1;
betweenMainDim -= isLastChild ? gap : 0; This should fix it. I need to do a buck setup to run tests, did it a long ago, will try again 😅 |
The Buck setup in OSS is no longer a thing (still need to add a CMake build for the GTest UTs instead), but I can run the tests internally if you make a PR. |
Thanks, @NickGerleman created a PR.
Yeah, I tried running it. Looks like I'll have to downgrade the java version to 8 😅. Let me know if something fails. |
I would suggest to just send a PR and let the CI run Buck tests in OSS for you. |
@cortinico got it. I sent it to the Yoga repo facebook/yoga#1188. Should I send it here as well? |
Sorry I thought you were talking about Buck tests for React Native and not yoga. I've just triggered the CI for Yoga so you can iterate there 👍 |
…ng when children determine parents main axis size) (#1188) Summary: Fixes - facebook/react-native#35553 ## Approach We're using `betweenMainDim` to add [gap between](https://github.com/intergalacticspacehighway/yoga/blob/bbeede82d36cd89657faf385aaa704f45443c326/yoga/Yoga.cpp#L2495) items in main axis. This is resulting in increased [main axis](https://github.com/intergalacticspacehighway/yoga/blob/bbeede82d36cd89657faf385aaa704f45443c326/yoga/Yoga.cpp#L2598) dimension of the container as it gets added even for the last element. One solution is to keep using it and subtract the gap when last element is reached. ## Aside Mutating this value feels weird, but I think `betweenMainDim` gets initialized for every line so should be fine? I did some manual tests to verify. I tried running tests but I'll have to downgrade the java version. Let me know if anything fails. Thanks! 🙏 Pull Request resolved: #1188 Test Plan: Added fixtures which previously failed but now pass. Reviewed By: necolas Differential Revision: D42078162 Pulled By: NickGerleman fbshipit-source-id: 0e535618350422e001141a8786a83fc81651afe9
…ng when children determine parents main axis size) (#1188) Summary: Fixes - facebook/react-native#35553 ## Approach We're using `betweenMainDim` to add [gap between](https://github.com/intergalacticspacehighway/yoga/blob/bbeede82d36cd89657faf385aaa704f45443c326/yoga/Yoga.cpp#L2495) items in main axis. This is resulting in increased [main axis](https://github.com/intergalacticspacehighway/yoga/blob/bbeede82d36cd89657faf385aaa704f45443c326/yoga/Yoga.cpp#L2598) dimension of the container as it gets added even for the last element. One solution is to keep using it and subtract the gap when last element is reached. ## Aside Mutating this value feels weird, but I think `betweenMainDim` gets initialized for every line so should be fine? I did some manual tests to verify. I tried running tests but I'll have to downgrade the java version. Let me know if anything fails. Thanks! 🙏 X-link: facebook/yoga#1188 Reviewed By: necolas Differential Revision: D42078162 Pulled By: NickGerleman fbshipit-source-id: 0e535618350422e001141a8786a83fc81651afe9
…ng when children determine parents main axis size) (#1188) Summary: Fixes - #35553 ## Approach We're using `betweenMainDim` to add [gap between](https://github.com/intergalacticspacehighway/yoga/blob/bbeede82d36cd89657faf385aaa704f45443c326/yoga/Yoga.cpp#L2495) items in main axis. This is resulting in increased [main axis](https://github.com/intergalacticspacehighway/yoga/blob/bbeede82d36cd89657faf385aaa704f45443c326/yoga/Yoga.cpp#L2598) dimension of the container as it gets added even for the last element. One solution is to keep using it and subtract the gap when last element is reached. ## Aside Mutating this value feels weird, but I think `betweenMainDim` gets initialized for every line so should be fine? I did some manual tests to verify. I tried running tests but I'll have to downgrade the java version. Let me know if anything fails. Thanks! 🙏 X-link: facebook/yoga#1188 Reviewed By: necolas Differential Revision: D42078162 Pulled By: NickGerleman fbshipit-source-id: 0e535618350422e001141a8786a83fc81651afe9
…ng when children determine parents main axis size) (#1188) Summary: Fixes - #35553 ## Approach We're using `betweenMainDim` to add [gap between](https://github.com/intergalacticspacehighway/yoga/blob/bbeede82d36cd89657faf385aaa704f45443c326/yoga/Yoga.cpp#L2495) items in main axis. This is resulting in increased [main axis](https://github.com/intergalacticspacehighway/yoga/blob/bbeede82d36cd89657faf385aaa704f45443c326/yoga/Yoga.cpp#L2598) dimension of the container as it gets added even for the last element. One solution is to keep using it and subtract the gap when last element is reached. ## Aside Mutating this value feels weird, but I think `betweenMainDim` gets initialized for every line so should be fine? I did some manual tests to verify. I tried running tests but I'll have to downgrade the java version. Let me know if anything fails. Thanks! 🙏 X-link: facebook/yoga#1188 Reviewed By: necolas Differential Revision: D42078162 Pulled By: NickGerleman fbshipit-source-id: 0e535618350422e001141a8786a83fc81651afe9
Fix should be ported to 0.71-stable now. |
…ng when children determine parents main axis size) (facebook#1188) Summary: Fixes - facebook#35553 ## Approach We're using `betweenMainDim` to add [gap between](https://github.com/intergalacticspacehighway/yoga/blob/bbeede82d36cd89657faf385aaa704f45443c326/yoga/Yoga.cpp#L2495) items in main axis. This is resulting in increased [main axis](https://github.com/intergalacticspacehighway/yoga/blob/bbeede82d36cd89657faf385aaa704f45443c326/yoga/Yoga.cpp#L2598) dimension of the container as it gets added even for the last element. One solution is to keep using it and subtract the gap when last element is reached. ## Aside Mutating this value feels weird, but I think `betweenMainDim` gets initialized for every line so should be fine? I did some manual tests to verify. I tried running tests but I'll have to downgrade the java version. Let me know if anything fails. Thanks! 🙏 X-link: facebook/yoga#1188 Reviewed By: necolas Differential Revision: D42078162 Pulled By: NickGerleman fbshipit-source-id: 0e535618350422e001141a8786a83fc81651afe9
Description
gap
/rowGap
adds an unwanted gutter (space) to the last layout element.Version
0.71.0-rc.3
Output of
npx react-native info
Steps to reproduce
The code example below is self-explanatory.
Snack, code example, screenshot, or link to a repository
The text was updated successfully, but these errors were encountered: