sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

SPFx v1.4.1 sp-office-ui-fabric-core styles not rendered/loaded

Open cperson opened this issue 7 years ago • 98 comments

Category

  • [x ] Question
  • [ ] Typo
  • [x ] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

The following classes referenced in an SPFx 1.4.1 solution would render appropriately : ms-Grid-col ms-sm3 ms-md3

Observed Behavior

Styles are not rendered based on classname.

This is happening as of 11/15/2019 at 2:00pm CST.

Steps to Reproduce

Create an SPFx v1.4.1 solution

Add the following line to you .scss: @import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';

Add any className from UI Fabric (i.e. ms-Grid-col)

Deploy solution and observe css is not rendered.

QUESTION: Would it be possible to provide reference of CDN paths as it relates to SPFx and Office UI Fabric resources, or otherwise elaborate on how the styles are added to the markup?

We are attempting to root cause this issue with no luck, and the best reference we can find refers to Icons specifically. It would be nice to have docs regarding styles as well: https://github.com/OfficeDev/office-ui-fabric-react/wiki/using-icons

cperson avatar Nov 15 '19 20:11 cperson

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Nov 15 '19 20:11 msft-github-bot

Same problem started two hours ago on one my my tenants on all my apps. On another tenant based on another continent they are still working fine for now. Spfx versions from 1.4.1 to 1.9.1.

Dangerous-Mind avatar Nov 15 '19 22:11 Dangerous-Mind

Slowly all tenants start seeing this issue. Root cause: old spfx solution having office fabric classes written directly in html markup.
Refer https://docs.microsoft.com/en-us/sharepoint/dev/spfx/office-ui-fabric-integration We can resolve this by rewriting the code to follow mixin systax for office fabric classes.

However it unfair to ask developers to rewrite previously working code which was written year ago and ask them now to rebuild the code all of sudden. So please provide support for 'global css syntax' for old version of code. Impose any new rule only for lastest version of the spfx solution

mmohamedbasith avatar Nov 16 '19 13:11 mmohamedbasith

Digging into this. Is it possible to give some more info on tracking this down. Are there errors in the console? Are specific files not getting downloaded (check the network tab for 404s)? Do you have a small example of code that shows the issue?

patmill avatar Nov 16 '19 23:11 patmill

My African tenant is back to normal. The European is still without css. No 403 error.

@patmill Some people usually use the ClassName= {"ms-Grid-col ms-sm12 ms-lg6"} syntax instead of doing include in scss and then applying it on the elements because is simpler and people don't have to load more css on to the page. Now Microsoft removed that css.

Ex: On the African Server they have: .ms-SPLegacyFabricBlock .ms-lg6 { width: 50%; } On the European server there is no definition on this class.

Dangerous-Mind avatar Nov 17 '19 02:11 Dangerous-Mind

@patmill Please let me know if you require any further information apart from @Dangerous-Mind given. Looking for a Quick resolution since most of these spfx solution will be on Production

mmohamedbasith avatar Nov 17 '19 03:11 mmohamedbasith

@mmohamedbasith @Dangerous-Mind can you provide CDN URLs which are not serving the scoped selectors e.g. .ms-lg6 NOT .ms-SPLegacyFabricBlock .ms-lg6. That is unexpected; all CDNs should be serving scoped styles e.g. .ms-SPLegacyFabricBlock .ms-lg6.

Also, what does running the following JavaScript code on the impacted page(s) return:

document.querySelectorAll('.ms-SPLegacyFabricBlock')

The above should return a NodeList with length > 0. Those DOM Nodes should wrap the SPFx solutions so the scoped styles are applied.

The Fabric styles are scoped to the above .ms-SPLegacyFabricBlock selector.

If the CDN is serving the scoped styles as expected, then can you try a mitigation of appending the following className .ms-SPLegacyFabricBlock to your solution's root DOM Node?

KevinTCoughlin avatar Nov 17 '19 03:11 KevinTCoughlin

Does anyone have an isolated SPFx 1.4.1 solution repro to expedite resolution?

KevinTCoughlin avatar Nov 17 '19 04:11 KevinTCoughlin

@KevinTCoughlin document.querySelectorAll('.ms-SPLegacyFabricBlock') gives zero nodes. However couple of hours ago i did saw SPFX webparts are wrapped with class 'ms-SPLegacyFabricBlock', not now.

No Apparent error in console. So I cannot find what is the CDN url missing .

mmohamedbasith avatar Nov 17 '19 04:11 mmohamedbasith

@KevinTCoughlin document.querySelectorAll('.ms-SPLegacyFabricBlock') gives zero nodes. However couple of hours ago i did saw SPFX webparts are wrapped with class 'ms-SPLegacyFabricBlock', not now.

No Apparent error in console. So I cannot find what is the CDN url missing .

Is the content cached? SPFx solutions in latest release should be wrapped in the above selector as you saw a few hours ago.

Does manually appending .ms-SPLegacyFabricBlock to the DOM Node containing the SPFx solution mitigate the styling issue?

KevinTCoughlin avatar Nov 17 '19 04:11 KevinTCoughlin

.ms-SPLegacyFabricBlock

Yes manually appending class 'ms-SPLegacyFabricBlock' from developer tools, render fabric css properly.

However what i remember couple of hours ago was , i saw the class 'ms-SPLegacyFabricBlock' in webpart but the css not applied. Now i dont see the class 'ms-SPLegacyFabricBlock' in html And Contents are not cached . i removed all the cache and checked . still dont find the class.

mmohamedbasith avatar Nov 17 '19 04:11 mmohamedbasith

I believe the following SPFx 1.4.1 WebPart sample solution exhibits the above mentioned problem: https://github.com/KevinTCoughlin/spfx-fabric-icons/blob/309ab6fafc381698d488fc021b7480dae8587026/src/webparts/helloWorld/HelloWorldWebPart.ts#L31

Is the above linked usage of Fabric Icon classNames similar to what is in-use in the regressed SPFx solutions?

KevinTCoughlin avatar Nov 17 '19 16:11 KevinTCoughlin

I believe the following SPFx 1.4.1 WebPart sample solution exhibits the above mentioned problem: https://github.com/KevinTCoughlin/spfx-fabric-icons/blob/309ab6fafc381698d488fc021b7480dae8587026/src/webparts/helloWorld/HelloWorldWebPart.ts#L31

Is the above linked usage of Fabric Icon classNames similar to what is in-use in the regressed SPFx solutions?

Yeah similar type, but can try below html with office fabric classes directly written in html

div className="ms-Grid" dir="ltr"> div class="ms-Grid-row"> div className="ms-Grid-col ms-sm6 ms-md4 ms-lg2">A

div className="ms-Grid-col ms-sm6 ms-md8 ms-lg10">B
/div> /div>

https://developer.microsoft.com/en-us/fabric#/styles/web/layout

mmohamedbasith avatar Nov 17 '19 16:11 mmohamedbasith

Comparing the two tenants. The Working one has the ms-SPLegacyFabricBlock class. I have the same problem in all SPFx versions. So it's not a SPFx version issue.

European Tenant (Not working): /<div class="Canvas-slideUpIn" data-sp-feature-tag="SupportStatisticsWebPart web part (Support Statistics)" data-sp-feature-instance-id="6948c5bd-c3ac-424e-b7bb-ad0f581dca1c" style="opacity: 0;">/<div style="width: 100%;">

African Tenant (Working) /<div class="Canvas-slideUpIn" data-sp-feature-tag="EnergyManagementWebPart web part (Energy Management)" data-sp-feature-instance-id="bfe68df2-2d24-4430-ae4e-75848f32b8b6" style="opacity: 0;"> /<div style="width: 100%;" class="ms-SPLegacyFabricBlock">

If I add the class to the non working tenant it will display correctly.

Dangerous-Mind avatar Nov 17 '19 17:11 Dangerous-Mind

Comparing the two tenants. The Working one has the ms-SPLegacyFabricBlock class. I have the same problem in all SPFx versions. So it's not a SPFx version issue.

European Tenant (Not working): /<div class="Canvas-slideUpIn" data-sp-feature-tag="SupportStatisticsWebPart web part (Support Statistics)" data-sp-feature-instance-id="6948c5bd-c3ac-424e-b7bb-ad0f581dca1c" style="opacity: 0;">/<div style="width: 100%;">

African Tenant (Working) /<div class="Canvas-slideUpIn" data-sp-feature-tag="EnergyManagementWebPart web part (Energy Management)" data-sp-feature-instance-id="bfe68df2-2d24-4430-ae4e-75848f32b8b6" style="opacity: 0;"> /<div style="width: 100%;" class="ms-SPLegacyFabricBlock">

If I add the class to the non working tenant it will display correctly.

Yeah. All tenant spfx with fabric following 'global css syntax' will have this issue. If MS can brought in the class 'ms-SPLegacyFabricBlock' in all tenant, it would solve the problem.

Anyhow latest spfx version 1.8.2,1.9.1 does not support global style css by default. Mostly the people follow mixins.so support is required for old versions spfx where css classes can be written in html itself.

mmohamedbasith avatar Nov 18 '19 00:11 mmohamedbasith

We've tested a fix which resolves the issue we were seeing above. We'll be rolling it out now thru tomorrow.

KevinTCoughlin avatar Nov 18 '19 03:11 KevinTCoughlin

@KevinTCoughlin . Much appreciated for the swift response 👍

mmohamedbasith avatar Nov 18 '19 04:11 mmohamedbasith

Thanks for fixing this this fast! This makes a couple of our customers very happy.

ghost avatar Nov 18 '19 08:11 ghost

Our quick and dirty trick was to include these styles manually via the header extention; until this issues is fixed.

https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.min.css

GnosisCode avatar Nov 18 '19 10:11 GnosisCode

Currently, the fabric grid CSS file is not loading. As a quick fix, we can load it in our solution. Create .scss file you can name it as "global.scss" (just a name) and import the mixins and variables for the grid system.

:global() {
  @import "~office-ui-fabric-react/dist/sass/mixins/Grid.Mixins";
  @import "~office-ui-fabric-react/dist/sass/mixins/General.Mixins";
  @import "~office-ui-fabric-react/dist/sass/mixins/Directionality.Mixins";
  @import "~office-ui-fabric-react/dist/sass/mixins/Responsive.Mixins";

  @import "~office-ui-fabric-react/dist/sass/variables/Responsive.Variables";

  @import "~office-ui-fabric-react/dist/sass/_Grid.scss";
  @import "~office-ui-fabric-react/dist/sass/_Responsive.scss";
}

Then import this file in your web part file

import '../shared/theme/global.scss';

Now you can use ms-* classes. For eg:

<div className={`ms-Grid-col ms-xxxl12 ms-xxl12 ms-xl12 ms-lg12 ms-md12 ms-sm12`}>
    12 column
</div>

Note: I'm using SPFx & React.

makafsal avatar Nov 18 '19 11:11 makafsal