You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-grid] error case of placement against missing lines needs example #966
But fail to define it in grid-template-areas I end up with an additional column as well. The item c is placed in the bottom right cell.
The implementations are both treating this is the same way (Chrome 58 and Firefox 52), but the issue has confused another author who asked me about it, and I'm unsure as to why the second example (a named item without a place on the grid) would auto-place differently to the first (an unnamed item without a place on the grid).
And if you add a D grid item and give it 'grid-area: d' it overlaps the placement of C.
My read of the algorithm makes me think that c is no longer auto positioned when it has a grid-area set, so it moves up to getting placed in step 1 rather than step 4, and therefore step 3 is creating an additional column and row for it.
This might be useful if the algorithm were creating new rows and columns for each undeclared area, but lumping all unknown positioning in the same place seems bad.
Perhaps we should change definite grid position from "at least one specified line" to "at least one specified line defined on the grid container"? Then C could fall back to auto positioning.
Good sleuthing! I was looking at the stuff around auto-placement. This seems reasonably odd behaviour from the point of view of an author so an example here https://drafts.csswg.org/css-grid/#grid-auto-flow-property would be good. I can put something together.
Rachel, I'm giving you blanket permission to add whatever examples or figures you think are necessary to any of my specs. :) Just ping me if you'd like me to look it over, and make sure they are marked up correctly (e.g. using class=example or class=figure as appropriate.)
ok - will do. Would you like me just to make a pull request for anything like this? There are a couple of images in the grid spec that really need redoing as SVG (a hand drawn one and one that was a screenshot of my example) which I keep meaning to look at too.
This doesn't have anything to do with auto-placement - all the items are explicitly placed, after all. This is about line names.
When you say grid-area: c;, that expands to grid-row-start: c-start; grid-row-end: c-end; grid-column-start: c-start; grid-column-end: c-end;. None of these named lines exist in the grid - the only named lines are a-start, a-end, b-start, and b-end (all implicitly created by grid-template) in each axis. However, lines in the implicit grid have all possible names, so the line-search ends up finding the first implicit line in each axis for all the properties. Grid areas aren't allowed to span zero tracks, so the end line gets pushed out by one, to the second implicit line.
Thus, the C item starts on line 3 (the first implicit line) and ends on line 4 in each axis, leaving one empty track around the edge of the implicit grid (between lines 2 and 3). You don't see the empty column, because it's "auto" sized and collapses to 0 size, but the empty row is 100px high due to grid-auto-rows.
A D item with grid-area: d gets put in the exact same place, for the same reason.
This behavior is intentional. It's an error case, whose behavior falls out of the generic behavior we purposely defined for finding non-existent line names. We're not interested in making this case act "better", because failing obviously and in a slightly weird way makes it more likely the author will see that something's wrong and will fix it.
If you really feel like calling out a case like this would help, @rachelandrew, feel free to draw up an example. But it's definitely an error case and will stay that way. ^_^
changed the title [-][css-grid] auto-placement of item named with grid-area, but without a corresponding placement in grid-template-areas[/-][+][css-grid] error case of placement against missing lines needs example[/+]on Mar 30, 2017
Activity
astearns commentedon Jan 21, 2017
And if you add a D grid item and give it 'grid-area: d' it overlaps the placement of C.
My read of the algorithm makes me think that c is no longer auto positioned when it has a grid-area set, so it moves up to getting placed in step 1 rather than step 4, and therefore step 3 is creating an additional column and row for it.
https://drafts.csswg.org/css-grid/#auto-placement-algo
This might be useful if the algorithm were creating new rows and columns for each undeclared area, but lumping all unknown positioning in the same place seems bad.
Perhaps we should change definite grid position from "at least one specified line" to "at least one specified line defined on the grid container"? Then C could fall back to auto positioning.
astearns commentedon Jan 21, 2017
In any case we should have an example in the spec that mentions what happens when you try to use an undefined grid area/line
astearns commentedon Jan 21, 2017
Ah, Example 37 in https://drafts.csswg.org/css-grid/#line-placement already mentions a version of this, and I found some discussion of this from last year: https://lists.w3.org/Archives/Public/www-style/2016Feb/0005.html
Lines on the implicit grid are defined to match all names, so by the current spec both implementations are correct.
rachelandrew commentedon Jan 22, 2017
Good sleuthing! I was looking at the stuff around auto-placement. This seems reasonably odd behaviour from the point of view of an author so an example here https://drafts.csswg.org/css-grid/#grid-auto-flow-property would be good. I can put something together.
fantasai commentedon Jan 24, 2017
Rachel, I'm giving you blanket permission to add whatever examples or figures you think are necessary to any of my specs. :) Just ping me if you'd like me to look it over, and make sure they are marked up correctly (e.g. using
class=exampleorclass=figureas appropriate.)rachelandrew commentedon Jan 25, 2017
ok - will do. Would you like me just to make a pull request for anything like this? There are a couple of images in the grid spec that really need redoing as SVG (a hand drawn one and one that was a screenshot of my example) which I keep meaning to look at too.
fantasai commentedon Jan 25, 2017
Sure, go ahead.
tabatkins commentedon Feb 2, 2017
This doesn't have anything to do with auto-placement - all the items are explicitly placed, after all. This is about line names.
When you say
grid-area: c;, that expands togrid-row-start: c-start; grid-row-end: c-end; grid-column-start: c-start; grid-column-end: c-end;. None of these named lines exist in the grid - the only named lines area-start,a-end,b-start, andb-end(all implicitly created bygrid-template) in each axis. However, lines in the implicit grid have all possible names, so the line-search ends up finding the first implicit line in each axis for all the properties. Grid areas aren't allowed to span zero tracks, so the end line gets pushed out by one, to the second implicit line.Thus, the C item starts on line 3 (the first implicit line) and ends on line 4 in each axis, leaving one empty track around the edge of the implicit grid (between lines 2 and 3). You don't see the empty column, because it's "auto" sized and collapses to 0 size, but the empty row is 100px high due to
grid-auto-rows.A D item with
grid-area: dgets put in the exact same place, for the same reason.This behavior is intentional. It's an error case, whose behavior falls out of the generic behavior we purposely defined for finding non-existent line names. We're not interested in making this case act "better", because failing obviously and in a slightly weird way makes it more likely the author will see that something's wrong and will fix it.
If you really feel like calling out a case like this would help, @rachelandrew, feel free to draw up an example. But it's definitely an error case and will stay that way. ^_^
[-][css-grid] auto-placement of item named with grid-area, but without a corresponding placement in grid-template-areas[/-][+][css-grid] error case of placement against missing lines needs example[/+]fantasai commentedon Oct 17, 2017
Closing as wontfix, please re-open if you feel strongly that this needs some edits.