Repository navigation
Description
From https://drafts.csswg.org/css-grid/#algo-grow-tracks,
If the free space is positive, distribute it equally to the base sizes of all tracks, freezing tracks as they reach their growth limits (and continuing to grow the unfrozen tracks as needed).
This step used not to be relevant for flexible tracks, because their growth limit is initially set to their base size.
However, since #2177, the growth limit can be increased in https://drafts.csswg.org/css-grid/#algo-spanning-flex-items
Increase sizes to accommodate spanning items crossing flexible tracks: Next, repeat the previous step instead considering [...] all items that do span a track with a flexible sizing function while
- treating flexible tracks as having a max track sizing function equal to their min track sizing function
- [...]
- distributing space to such tracks according to the ratios of their flexible sizing functions rather than distributing space equally
Therefore, consider https://jsfiddle.net/3kbz9j2g/
<div id="grid">
<div id="item"></div>
</div>#grid {
display: grid;
width: 100px;
grid-template-columns: 1fr 3fr;
border: solid;
}
#item {
grid-column: 1 / 3;
min-width: 0;
height: 100px;
background: cyan;
}
#item::before {
content: '';
display: block;
width: 200px;
}The minimum contribution of the item is 0 so it doesn't increase the base sizes of the tracks. But both tracks are treated as if they had an auto max track sizing function, so the max-content contribution of the item (200px) is distributed into growth limits, 50px to the first column and 150px into the 2nd one.
So we reach https://drafts.csswg.org/css-grid/#algo-grow-tracks as follows:
- Free space:
100px - 1st column: base size
0px, growth limit50px. - 2nd column: base size
0px, growth limit150px.
Then if the 100px are distributed equally:
- Free space:
0px - 1st column: base size
50px, growth limit50px. - 2nd column: base size
50px, growth limit150px.
And https://drafts.csswg.org/css-grid/#algo-flex-tracks is no-op since the free space is 0.
So the column ratios end up being 1:1 instead of 1:3. This doesn't look good to me. I think that
- either the "Maximize Tracks" should not distribute free space into flexible tracks, leaving this part to "Expand Flexible Tracks",
- or it should distribute space according to the flex ratios instead of equally (considering non-flexible tracks to have a ratio of 0, and distribute equally if the sum of ratios is 0? Not sure).
Activity
Loirooriol commentedon Mar 2, 2019
A more complex example:
https://jsfiddle.net/2rsLcwg8/
Before #2177 the track size ratios corresponded to their flex factors (because the minimum contributions are small enough). With the current spec, ratios are totally screwed. Maximizing tracks using their flex factor ratios improves them just a little bit. Not maximizing flexible tracks provides the old behavior, I think that's the expected one.
Loirooriol commentedon Mar 2, 2019
BTW, not maximizing flexible tracks should be equivalent to not increasing their growth limit, i.e. drop this:
What was this amendment trying to solve? I don't see this getting discussed in #2177.
[css-grid-1] After intrinsic sizing, flexible tracks should have a gr…
fantasai commentedon Jun 6, 2019
Flexible tracks shouldn't be affected by the "Maximize Tracks" section at all... I think what we should have done instead was calculate the base sizes and then just set the growth limits to the base sizes. Updated the spec to do that. r=Oriol Agenda+ to request WG review
css-meeting-bot commentedon Jun 19, 2019
The CSS Working Group just discussed
"Maximize Tracks" shouldn't distribute equally for flexible tracks, and agreed to the following:RESOLVED: Accept change in https://github.com/w3c/csswg-drafts/issues/3693The full IRC log of that discussion
<dael> Topic: "Maximize Tracks" shouldn't distribute equally for flexible tracks<dael> github: https://github.com//issues/3693
<dael> fantasai: this was another fix for errors
<dael> fantasai: There was a statement where we made a mistake saying treat max sizing same as min sizing. Trying to select a class of tracks and didn't use the right words.
<dael> astearns: Okay
<dael> fantasai: Just fixing an error. Happy is people want to look at it
<dael> astearns: Given issue discussion looks correct. oriol said it looks good
<dael> fantasai: These were co-edited with oriol so he thinks they're correct
<dael> astearns: Comments on this change? Objections?
<dael> RESOLVED: Accept change in https://github.com//issues/3693
Loirooriol commentedon Jul 3, 2019
@fantasai Thinking about this again, "treating flexible tracks as having an infinite growth limit" can make it seem that this is just a temporal thing just for step §11.5.4, and after that the growth limit is set back to its old value. But that's not the case, since §11.5.5 assumes flexible tracks will still have an infinite growth limit. So instead of "treating", maybe it should say "Set the growth limit of flexible tracks to infinity"? But then why not set that at the beginning in https://drafts.csswg.org/css-grid/#algo-init ? I think it would be equivalent, I don't remember if we considered it.
fantasai commentedon Nov 1, 2019
@Loirooriol I believe your last comment was handled in #4313 so marking the issue as closed. Please mark Commenter Satisfied if you are happy with the edits here. :)
Loirooriol commentedon Nov 1, 2019
Yes #4313 finished this, it seems good now.