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 isolation doesn't seem to work with lazy loaded assembly #26542

Closed
sm15455 opened this issue Oct 2, 2020 · 5 comments
Closed

CSS isolation doesn't seem to work with lazy loaded assembly #26542

sm15455 opened this issue Oct 2, 2020 · 5 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-lazy-loading Issues related to adding support for lazy-loading in Blazor feature-css-isolation This issue is related to CSS Isolation feature ✔️ Resolution: Duplicate Resolved as a duplicate of another issue

Comments

@sm15455
Copy link

sm15455 commented Oct 2, 2020

Hi,

I have a solution containing 2 projects: a Blazor RC1 project and library project.
The library contains a single component and is lazy loaded by the application. The component has a css file that follows css isolation naming rules. When I load the assembly, the assembly is correctly loaded and the component rendered, but the CSS file is ignored. The CSS for the component is not included in the scoped.style.css file (I think it's correct), but it's not even loaded at run time. Is it a bug or this scenario is simply not supported?

@pranavkm pranavkm added the area-blazor Includes: Blazor, Razor Components label Oct 2, 2020
@pranavkm
Copy link
Contributor

pranavkm commented Oct 2, 2020

FYI @captainsafia

@captainsafia captainsafia added feature-blazor-lazy-loading Issues related to adding support for lazy-loading in Blazor investigate labels Oct 2, 2020
@captainsafia captainsafia self-assigned this Oct 2, 2020
@captainsafia captainsafia added the feature-css-isolation This issue is related to CSS Isolation feature label Oct 2, 2020
@captainsafia captainsafia added this to the 5.0.0 milestone Oct 5, 2020
@captainsafia
Copy link
Member

@sm15455 Can you share a repro project? I was not able to repro this issue on 5.0.0-rc.2.20465.7 (note: RC2). Also, I assume you are using the lazy-loading feature as documented here.

FWIW, with the way that lazy-loading is setup, the isolated CSS is loaded when the application is launched. The CSS itself is applied when the component is instantiated. So the flow looks roughly like this.

  1. User navigates to page. Isolated component's scoped CSS file is loaded.
  2. User navigates to route with lazy-loaded assembly. Isolated component's scoped CSS is applied. Any resources referenced in the CSS are fetched.

@captainsafia captainsafia added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Working investigate labels Oct 5, 2020
@sm15455
Copy link
Author

sm15455 commented Oct 7, 2020

@captainsafia I have investigate the issue and have found my problem description to be misleading. Basically, everything works but a little exception. here is what I did.

  1. Created a new blazor project (RC1)
  2. Create a library project
  3. Moved the counter.razor file into the library
  4. Configured the project to lazy load the library (I used the official doc you linked)
  5. Pressed F5

Now the browser opens and everything is ok, the component is loaded. I close the browser and.

  1. Create a counter.razor.css file and add a css style to it.
  2. Pressed F5

Now the browser opens, and the component is loaded but the style is not applied because it's not included in the scoped.style.css file.
I found out that to make it work, I have to rebuild the entire solution after any change to the css file and then press F5.

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Oct 7, 2020
@captainsafia
Copy link
Member

@sm15455 Thanks for clarifying. It appears that your issue is specific to rebuilding CSS after making a modification and not the loading of a CSS file from the lazy-assembly. In particular, it looks like you might be running into a dupe of #26561.

@captainsafia captainsafia removed this from the 5.0.0 milestone Oct 7, 2020
@captainsafia
Copy link
Member

It looks like we resolved this issue with build incrementalism and CSS updates in VS as part of #24337. Closing this for now.

@captainsafia captainsafia added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Oct 7, 2020
@ghost ghost added the Status: Resolved label Oct 7, 2020
@captainsafia captainsafia removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. Status: Resolved labels Oct 7, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-lazy-loading Issues related to adding support for lazy-loading in Blazor feature-css-isolation This issue is related to CSS Isolation feature ✔️ Resolution: Duplicate Resolved as a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants