-
Notifications
You must be signed in to change notification settings - Fork 715
Implementations don't match the Flex Container Intrinsic Main Sizes algo, resulting in gratuitous differences from equivalent Grid layouts #1147
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
Comments
Further investigation by @fantasai and me shows that the spec is actually correct - if you follow 9.9.1 for the cases in my linked example, they all end up with identical results to Grid. So this looks like implementations bugs in Flexbox, across both Firefox and Chrome at least. (I can't easily test IE right now.) Maybe they didn't update impls after we fixed that section? |
Mozilla's bug is https://bugzilla.mozilla.org/show_bug.cgi?id=1055887 and @dholbert says he's planning to fix it. |
I'm using https://bugs.chromium.org/p/chromium/issues/detail?id=240765 for the Blink version of this bug, but yes, this is currently not fixed in Blink/Chrome. I am concerned about the compat implications; when I find time, I need to get better statistics than I currently have for this. |
Ugh, and the specced Flexbox behavior is broken. It double-applies fractions < 1 when the total sum is < 1. :((((( To be specific, check this case showing off Grid's behavior in a similar case. Chrome's impl happens to exactly match what the Flexbox says to do (if you translate things back to flex concepts). Note the first box - the max-content size of each item is 200px, so the .4fr calculates to 80px wide, and the .5fr to 100px wide. The grid container is thus 180px wide. Then grid layout happens normally, giving the .4fr column 40% of that space (72px) and the .5fr 50% of the space (90px), making both of them overflow (when only the .4fr one should be overflowing; the .5fr should precisely fit its children after linebreaking). In other words, the fraction gets double-applied. The fix to this is to check if the sum of flexes is <1, and if so, renormalize the flexes to sum to 1 for the purposes of section 9.9.1. That will produce a 200px wide container, making the .4fr be 80px wide and the .5fr be 100px wide, exactly as intended; this'll then match the (expected) behavior of the .5/1.0 case, where the .5fr column is 100px wide and the 1.0 column is 200px wide. (Alternately, do something more complicated in the layout algo to let it know that it's supposed to be snug, and we can ignore the normal behavior of <1 flex and just give it a corresponding share of the total. Both result in the same sizes for the tracks/flex items, but this makes the container smaller and snug around the items.) |
Filed Tab's issue as #1735. |
Closing this issue, with Tab's permission. |
Quoting myself from #1120:
Testcase showing off the differences: https://jsfiddle.net/7L9j7qjw/
The text was updated successfully, but these errors were encountered: