jss icon indicating copy to clipboard operation
jss copied to clipboard

[jss-vendor-prefixer] CSS Grid and Vendor prefix

Open arash87 opened this issue 7 years ago • 10 comments

Expected behavior: Hello When using CSS Grid with recat-jss I expect that Vendor prefix will kick in i IE and add the -ms prefix to some of the CSS Grid properties.

Describe the bug: Here is an example:

		'& .head-section': {
			display: 'grid',
			gridTemplateColumns: '1fr 1fr 240px',
			gridRow: props => props.notificationSection ? '2' : '1',
			gridColumn: '1 / span 2'
			padding: '0 30px',
		}

This works fine in Chrome or Firefox. In IE 11 however, I see the following css rules in developer tools:

display: -ms-grid;
-ms-grid-colum: 1 / span 2;
grid-template-columns: 1fr 1fr 240px;
grid-row: 2;

Notice that only the display property has correct propertyname and value. The other properties are flagged red in IE dev tools and are not applied.

According to Autoprefix, the other values should be pared like this for IE:

display: -ms-grid;
-ms-grid-colum: 1;
-ms-grid-column-span: 2;
ms-grid-columns: 1fr 1fr 240px;
ms-grid-row: 2;

Is there any reason for this behavior?

Codesandbox link:

Versions (please complete the following information):

  • react-jss: 8.6.1
  • Browser [e.g. chrome, safari]: IE 11
  • OS [e.g. Windows, macOS]: Windows

arash87 avatar Jan 31 '19 07:01 arash87

Can you please provide a codesandbox with a minimal reproducible example?

Also in your correct behavior, there is one more property than in the source. Where does the -ms-grid-column-span come from?

HenriBeck avatar Jan 31 '19 07:01 HenriBeck

@HenriBeck unable to run codesanbox in IE 11, but this is an example i made https://codesandbox.io/s/k08mv8790o

The following rule suggests that a container starts at column 1 and spans 2 columns. The -ms equivalent to this are 2 separate rules:

grid-column: 1 / span 2;
-ms-grid-column: 1;
-ms-grid-column-span: 2;

image

arash87 avatar Jan 31 '19 08:01 arash87

Not sure if we can fix that. I think the way we are currently auto-prefixing is trying to add the property; if the property is still being returned by getDynamicStyles we are using that property, otherwise, we go through the possible prefixes and try them.

HenriBeck avatar Jan 31 '19 08:01 HenriBeck

Explicitly defining the ms rules in jss file seems to be working. But do you think this is a solid solution / workaround for now?

I will end up with something like this:

display: 'grid',
msGridColumns: '1fr 1fr 240px',
msGridRow: props => props.notificationSection ? '2' : '1',
msGridColumn: '1',
msGridColumnSpan: '2',
gridTemplateColumns: '1fr 1fr 240px',
gridRow: props => props.notificationSection ? '2' : '1',
gridColumn: '1 / span 2'

arash87 avatar Jan 31 '19 08:01 arash87

This needs a bug fix/enhancement in css-vendor package cc @AleshaOleg

kof avatar Feb 04 '19 14:02 kof

I will take care of this issue this week thanks!

AleshaOleg avatar Feb 04 '19 16:02 AleshaOleg

Any update here?

fralewsmi avatar Nov 13 '19 23:11 fralewsmi

Any updates ?

ffjanhoeck avatar Jan 10 '20 08:01 ffjanhoeck

i've found the solution: '-ms-grid-column': 1, ... For same item but using other selector, It allows to prevent jss from replacing '-ms-...' rules in same selector.

AnatoliyLitinskiy avatar Jul 16 '20 18:07 AnatoliyLitinskiy

I will take care of this issue this week thanks! @AleshaOleg

Is this issue still under progress?

liranmery avatar Nov 04 '20 12:11 liranmery