-
Notifications
You must be signed in to change notification settings - Fork 25
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
row span and auto positionning in Firefox #2
Comments
I think the issue is in a difference in how Firefox is interpreting those empty rows vs. Chrome. If I add Should the auto size rows collapse to zero? That's what Chrome is doing. Or, should the space be distributed? This is what Firefox does. |
Thanks Rachel. |
I'd need to check the track sizing algorithm, but on a first sight it seems that Chromium is right as it doesn't increase the size of rows without a clear reason. Check this reduced example: https://codepen.io/mrego/pen/wqWbOg |
Yes, my initial feeling was that Chrome was doing the right thing. If there was nothing at all in the rows they would be zero height. The fact something spans them probably shouldn't make any difference. |
Chrome has bugs too, imo. |
In the test case by @mrego Blink is clearly the one behaving correctly. Without checking the algorithm is obvious that we are not increasing the sizes of the tracks if not needed, something that is a basis for all the heuristics used in the algorithm. Now the technical justification based on the algorithm. The relevant section is section 11.5, list item 2. where it says "Increase sizes to accommodate spanning items"
So the correct result is indeed [10,10] [10,10] [60, 60] |
Regarding the other example posted by @ledahulevogyre although it looks a bit weird it's correct in Chrome and again a bug in Firefox. Technically it's more complicated to explain than the above case. The algorithm sizes tracks by grouping items by the amount of span, meaning that it processes first the non-spanning items, then the ones spanning 2, then spanning 3... But there is one important thing to take into account, and is that when computing the track sizes for a particular span level it must do it independently on the DOM order of each item, meaning that if I have 2 items spanning 3 tracks, I should get the same result independently on how they're specified in the DOM. I've modified your example slightly. First I specified all the item positions so that autoplacement does not generate different results, and then created the very same example but switching the positions of items 2 and 3 in the source code. Since the track sizing algorithm should work independently of the order (https://drafts.csswg.org/css-grid/#distribute-extra-space), in Blink the result is the same in both cases as it should be, while in Firefox they behave differently. See: |
Thanks for all the digging into this! I have raised the two issues with Firefox:
I have linked to this discussion but please add comments to those reports if you feel I have not fully represented the issue at hand. Also added all of this as issue #12 on this site. |
Thank you @svillar |
So I'll try to explain it using the test case you've posted. As mentioned after processing the item spanning 2 rows the row sizes look like this: [10,10] [10,10] [0, inf] [0,inf] [0,inf] Now you need to process the other two items which span 3 columns. Item 2 spans rows 1,2 & 3 and item 3 spans rows 3,4 & 5. As I mentioned the algorithm ensures that the order in which you process items should not affect the final result. So the way it works is that we get candidate sizes for the tracks for every single item and then we run a final pass setting the sizes that make everything valid. These are the candidate sizes computed for each item spanning 3 rows: item 2 (height 80px) computes: [10,10] [10,10] [60, 60] [0,inf] [0,inf] So now you combine both results and get [10,10] [10,10] [60, 60] [6, 6] [6, 6]. You could think, "oh but you don't need nonzero tracks 4&5 because the item 3 already fits in row 3". That's true but you've explicitly set that the item spans through 3 auto rows so the right thing to do is to distribute equally among these tracks. Hope I have clarified your doubts |
I see now. Thanks for the explanation. |
I don't think this is a spec issue, you are of course able to raise issues against the spec if you want to. |
Not sure what you mean by "it's the layout order that should be prevalent" but what grid does is preciselly layout its tracks so that: |
But b) is not respected in this case. Or I misunderstood (quite possibly). |
I don't really follow your concern, however I'm not an editor of the specification so if you think there is an issue you should raise it against the spec itself. |
Here is an example of my concern : https://codepen.io/anon/pen/qXaygO?editors=1100 |
The appropriate place for spec discussion is on the spec where the editors can comment. |
@ledahulevogyre: what you must do is definitely a). Then you should try to do b) the best you can. If you think about it there is likely no better way to do that. You're explicitly asking to span 3 rows so you have to give them non-zero size. |
@ledahulevogyre: I don't deny that it might seems wrong to have a more compact grid when using an item that spans more tracks but the fact is that it's working as expected. I'll explain why. In the second grid you have items spanning 2,3 and 4 rows. So they'll be processed in 3 different steps. After processing the one spanning 2 you'd get [10,10] [10,10] [0,inf] [0,inf] [0,inf] [0,inf] then you process just the one spanning 3 (in grid 2 there is just 1) so you get [10,10] [10,10] [60,60] [0,inf] [0,inf] [0,inf] Now you process the one spanning 4. As track 3 has been already resolved in the previous step, the algorithm decides not to change anything, because the item has 20px height which perfectly fits in the current grid area already defined for tracks 3,4,5,6. Again I am not saying that it is not weird from the author POV but just wanted to clarify that is not a bug from the spec POV. As @rachelandrew suggested if you think this is a bug in the spec then feel free to report it. |
@svillar has this been fixed in the meantime? Just checked with FF DevEdition 62.0b16 (64-bit)/macOS and the second example renders the same way as it does in Chrome. |
No idea, let's ask @MatsPalgrem |
Here I try to layout 8 divs automatically, based on their row span definition.
https://codepen.io/anon/pen/Nvxdjo
Row heights appears to adapt well for the first 5 rows. But then, all the subsequent rows seem to have the height of the 5th row. The consequences are the blank spaces in the 4th and 5th divs.
The behavior seems good on Blink. It compresses the rows/divs as I expect.
The text was updated successfully, but these errors were encountered: