Re: [csswg-drafts] [css-grid-2] Resolving indefinite grid spans in nested subgrids (#6905)

Your pseudo-code was slightly unclear, so just to make sure we're talking about the same thing, is the following what you meant by your example?

```htmlmixed=
<div id=grandparent >
 <grid id=parent >
  <item style="grid-row: 1 / 2; grid-column: auto / auto"></item>
  <grid id=child></grid>
 </grid>
</grid>
<style>
    #grandparent {
        display: grid;
        grid: auto / repeat(10, 10px);
    }
    #parent {
        display: grid;
        grid: subgrid / subgrid;
        grid-column: 1 / 4;
        /* unspecified grid-row, thus "auto / span 1" by default */
    }
    #child {
        display: grid;
        grid: subgrid / subgrid [][][][];
        grid-row: 1 / 2;
        /* unspecified grid-column, thus "auto / span 3" from the subgrid lines */
    }
</style>
```

> Once we've placed the subgrid into the parent grid, we have an definite number of tracks that we span, and the subgrid must have exactly that number of tracks.

Right.

> We can't use the number of names from the grid-template-X: subgrid <> definition and have a different number of tracks without changing our placement in the parent.

Which is why we only calculate the span from the name list in cases where there is an indefinite span.

> I'm not sure I see how indefinite spans make things easier.

It's so the author doesn't have to specify the span number in multiple places. It's very easy for the UA to correctly infer a number of tracks from a subgrid's line name list, and also easy for the author to miscount and have an inconsistent span vs track list, especially when making edits, so we're making the UA do the work here.

> Afaict we did fail to specify that case, so I think the fix here is to do that?

This does seem to be correctly specified in https://www.w3.org/TR/css-grid-2/#subgrid-implicit

> This means that a subgrid might have fewer tracks than it expected, either because its parent is a subgrid and therefore has a fixed number of tracks, or because its parent is hitting the UA limit on grid tracks.

We might want to add these implications as a note, though.

The alternative would be to allow the subgrid to have implicit tracks that overflow the subgrid, into tracks whose sizes and positions are borrowed from the parent grid but are physically outside the borders of the subgrid's box. (This could feel a little weird when mixed with `overflow: scroll` but it would work.)

~fantasai and Tab

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


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

Received on Monday, 31 January 2022 23:28:24 UTC