Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

ngStyle not being inlined for SSR #813

Closed
rkajbaf opened this issue Aug 1, 2018 · 6 comments · Fixed by #962
Closed

ngStyle not being inlined for SSR #813

rkajbaf opened this issue Aug 1, 2018 · 6 comments · Fixed by #962
Assignees
Labels
bug has pr A PR has been created to address this issue P1 Urgent issue that should be resolved before the next re-lease ssr
Milestone

Comments

@rkajbaf
Copy link

rkajbaf commented Aug 1, 2018

Bug Report

The SSR docs suggest we inline all flex related styles so that they will work in SSR. This works for flexHide/flexShow etc but does not appear to work for ngStyle.

What is the expected behavior?

ngStyle.xs, etc styles are also inlined using media queries similarly to fxHide.

What is the current behavior?

ngStyle is ignored on SSR.

What are the steps to reproduce?

Providing a StackBlitz (or similar) is the best way to get the team to see your issue.

Hard to give a StackBlitz since its an SSR related issue, but anything like this

[ngStyle.xs]="{'margin-top': '56px'}" does not make it into the SSR rendered version.

What is the use-case or motivation for changing an existing behavior?

SSR should look like regular version, or as close as possible.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

 Angular 6.0.7
 Material 6.3.1
 WIndows 10
 TypeScript 2.7.2`

Is there anything else we should know?

No

@CaerusKaru CaerusKaru added bug P1 Urgent issue that should be resolved before the next re-lease ssr labels Aug 2, 2018
@CaerusKaru CaerusKaru self-assigned this Aug 2, 2018
@CaerusKaru CaerusKaru added this to the v6.0.0-beta.18 milestone Aug 2, 2018
@rkajbaf
Copy link
Author

rkajbaf commented Aug 2, 2018

@CaerusKaru thanks!

@Antti-Kaikkonen
Copy link

ngClass seems to have the same issue.

@CaerusKaru
Copy link
Member

CaerusKaru commented Nov 19, 2018

@Antti-Kaikkonen as mentioned briefly in the SSR design doc, there is no solution for using NgClass on the server. This is because it's impossible to "toggle" classes based on static media query generation.

NgStyle, on the other hand, should work, since it's just appending those styles to the right style block.

PS If you think you have a solution to the NgClass issue, I'd be more than happy to discuss design/review a PR.

EDIT: For posterity, one possible implementation solution for ngClass is to alias it on the server to mean ngStyle.<bp> && ngShow.<bp> for all breakpoints, and insert more DOM nodes to cover the spread. These would then have to be cleaned up in the browser. There are possible performance/correctiveness issues especially if the nodes have children.

@CaerusKaru
Copy link
Member

This may be patched in #900. @rkajbaf can I count on you to verify once it lands?

@CaerusKaru CaerusKaru added the has pr A PR has been created to address this issue label Dec 28, 2018
@CaerusKaru
Copy link
Member

This wasn't patched by #900 but will be patched in #962, and will be included in the beta 23 release some time next month.

CaerusKaru added a commit that referenced this issue Dec 28, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug has pr A PR has been created to address this issue P1 Urgent issue that should be resolved before the next re-lease ssr
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants