Re: [csswg-drafts] [css-grid-1] Intrinsic contributions across spanning items and fractional flex items (#5375)

Seems to me that this behavior is already specified. For example, for `grid-template-columns: 0.5fr auto; float: left`, this is what implementations do:

- The track sizing algorithm ignores the contribution of the item with span > 1 and flex tracks. So we reach https://drafts.csswg.org/css-grid/#algo-flex-tracks with a base size and growth limit of 0.
- We are sizing the grid container under a max-content constraint, so the free space is indefinite, and the used flex fraction is the maximum of:
   - The base size, 0, since the flex fraction <= 1
   - The result of finding the size of an fr using both tracks and a space to fill of 36px (the max-content contribution). This is 36px.
- So the base size of the flex track is set to `0.5*36px = 18px`.
- Then the content size of the grid container is set to `18px + 0px = 18px`, and we lay it out again "for real".
- Again, the track sizing algorithm ignores the contribution of the item with span > 1 and flex tracks. So we reach https://drafts.csswg.org/css-grid/#algo-flex-tracks with a base size and growth limit of 0.
- This time the free space is a definite length (18px), so the used flex fraction is the result of finding the size of an fr using both tracks and a space to fill of 18px. This is 18px.
- So the base size of the flex track is set to `0.5*18px = 9px`.
- So we have a remaining free space of `18px - 9px = 9px`, and the auto track is stretched to cover that.

It's simpler for `grid-template-columns: 0.5fr auto; width: 3em`:

- The track sizing algorithm ignores the contribution of the item with span > 1 and flex tracks. So we reach https://drafts.csswg.org/css-grid/#algo-flex-tracks with a base size and growth limit of 0.
- The free space is a definite length (36px), so the used flex fraction is the result of finding the size of an fr using both tracks and a space to fill of 36px. This is 36px.
- So the base size of the flex track is set to `0.5*36px = 18px`.
- So we have a remaining free space of `36px - 18px = 18px`, and the auto track is stretched to cover that.

But, the thing is that according to https://drafts.csswg.org/css-grid/#track-size-intrinsic-min

> If the grid container is being sized under a min- or max-content constraint, use the items’ limited min-content contributions in place of their minimum contributions here.

So actually, when sixing under a max-content constraint, the base size and growth limit of the flex track should be 36px. So the content size of the grid container should also become 36px, and then the result should look like the `width: 3em` case.

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5375#issuecomment-667107494 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 31 July 2020 13:00:36 UTC