Skip to content
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

[css grid] Overriding a grid-area assignment with more specific one may result in incorrect -ms-grid-(row|column)-span #1292

Open
argv-minus-one opened this issue Mar 12, 2020 · 2 comments
Labels

Comments

@argv-minus-one
Copy link

Autoprefixer does not seem to know that it should output -ms-grid-(row|column)-span: 1 when a grid-area assignment (that spans only one row/column) overrides another, less specific one (that spans multiple rows/columns).

Using Autoprefixer 9.7.4 and PostCSS 7.0.27. This issue seems similar to #1146, but that was fixed already, so this one must be different somehow.

Here's an example:

Command line

postcss --use autoprefixer -o output.css input.css

Input

/* autoprefixer grid: autoplace */

body {
	display: grid;
	grid-template:
		"other other"
		"one   two  ";
}

body > * {
	grid-area: other;
}

body > .one {
	grid-area: one;
}

body > .two {
	grid-area: two;
}

Output

/* autoprefixer grid: autoplace */

body {
	display: -ms-grid;
	display: grid;
	-ms-grid-rows: auto;
	    grid-template:
		"other other"
		"one   two  ";
}

body > * {
	-ms-grid-row: 1;
	-ms-grid-column: 1;
	-ms-grid-column-span: 2;
	grid-area: other;
}

body > .one {
	-ms-grid-row: 2;
	-ms-grid-column: 1;
	grid-area: one;
}

body > .two {
	-ms-grid-row: 2;
	-ms-grid-column: 2;
	grid-area: two;
}

This leaves .one and .two with an effective -ms-grid-column-span: 2, which does not match the grid-template.

This also applies to -ms-grid-row-span. Assigning to a grid-area spanning multiple rows, then overriding it with a more specific grid-area assignment that doesn't span multiple rows, will also result in a missing -ms-grid-row-span: 1.

Expected output

/* autoprefixer grid: autoplace */

body {
	display: -ms-grid;
	display: grid;
	-ms-grid-rows: auto;
	    grid-template:
		"other other"
		"one   two  ";
}

body > * {
	-ms-grid-row: 1;
	-ms-grid-column: 1;
	-ms-grid-column-span: 2;
	grid-area: other;
}

body > .one {
	-ms-grid-row: 2;
	-ms-grid-column: 1;
	-ms-grid-column-span: 1;
	grid-area: one;
}

body > .two {
	-ms-grid-row: 2;
	-ms-grid-column: 2;
	-ms-grid-column-span: 1;
	grid-area: two;
}

Workaround

Give the missing -ms-grid-column-span explicitly in the input:

body > .one, body > .two {
	-ms-grid-column-span: 1;
}
@ai ai added the bug label Mar 12, 2020
@ai
Copy link
Member

ai commented Mar 12, 2020

Hi. Thanks for the issue. You really fill it very well.

I will be happy to accept and release PR. Sorry, I do not improve Grid support (since IE is dying). But I can help you. You should start with lib/hacks/grid-template.js.

@argv-minus-one
Copy link
Author

argv-minus-one commented Mar 12, 2020

That's understandable. I wish I could ignore IE too, but it still accounts 3.76% of my page views last month. It is dying, but it's not dead yet.

Unfortunately, I can't make sense of the Autoprefixer/PostCSS code. Dynamic typing makes my head spin. So, I'll have to live with the workaround.

@postcss postcss deleted a comment from giambilos Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants