Skip to content

[Sidenav] Not opened for server-side render #8969

Open

Description

@alirezamirian

Bug, feature request, or proposal:

bug

What is the expected behavior?

sidenav being opened when rendered on server. Here is my usage:

... <mat-sidenav [opened]="true"></mat-sidenav> ...

It works on browser but not on server side rendering.

What is the current behavior?

It renders closed.

What are the steps to reproduce?

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

SSR

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

Angular CLI: 1.5.4
Node: 6.9.1
OS: win32 x64
Angular: 5.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

@angular/cdk: 5.0.0-rc.2
@angular/cli: 1.5.4
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/language-service: 4.4.6
@angular/material: 5.0.0-rc.2
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.4
@schematics/angular: 0.1.7
typescript: 2.4.2
webpack: 3.8.1

Activity

  1. changed the title [-]Sidenav is not opened in server side rendering[/-] [+][Sidenav] Not opened for server-side render[/+] on Dec 15, 2017
  2. added
    P3
    on Dec 15, 2017
  3. agustinhaller commented on Mar 13, 2018

    @agustinhaller

    @andrewseguin Hi, any updates on this? In my case it's not working with Angular 5.2.8 and material 5.2.4

  4. mmalerba commented on Mar 14, 2018

    @mmalerba
    Contributor

    This was fixed, but based on @agustinhaller's comment from #6865 it sounds like maybe there was a regression at some point.

    Hi, any updates on this? In my case it was working OK with Angular 5.0.2 and material 5.0.0.rc0 but stop working when updated to Angular 5.2.8 and material 5.2.4

  5. added
    P2
    regression
    and removed
    P3
    on Mar 14, 2018
  6. jelbourn commented on Apr 5, 2018

    @jelbourn
    Contributor

    @crisbeto could you take a look? Got an escalation on this one

  7. fazpu commented on Jun 27, 2018

    @fazpu

    Still not resloved :( This make the sidenav rather unusable if using Universal.

  8. jelbourn commented on Jun 27, 2018

    @jelbourn
    Contributor

    This appears to have been caused by a bug in @angular/animations that should have recently been fixed in Angular's master.

  9. mario-merino commented on May 9, 2019

    @mario-merino

    Still waiting... any ideas when could be solved?
    thanks

  10. intellix commented on Oct 26, 2019

    @intellix

    Tried to workaround this by doing something like: [style.margin-left.px]="isHandset ? 0 : 200" but the null removes it from universal but you can get away with it if you add some styles:

    <mat-sidenav-content [ngClass]="{ mobile: isHandset }">
    mat-sidenav-content {
      margin-left: 200px;
    
      &.mobile {
        margin-left: 0;
      }
    }

    Our widths are dynamic as they come from the CMS so it's not ideal but better than nothing!

  11. chenlijun99 commented on Apr 19, 2020

    @chenlijun99

    I'm facing a similar issue. The sidenav renders open, but no margin is applied to the mat-drawer-content.

    <mat-drawer-content class="mat-drawer-content" style="margin-left:;margin-right:;">
  12. KeithKelleher commented on Jul 10, 2020

    @KeithKelleher

    I ran into this in Angular 9 & 10 still. For me the sidenav renders over the content panel, when it's supposed to be on the side.

    As a workaround, I'll probably add a class to mat-sidenav-content when isPlatformServer(this.platformID) to adjust margin-left. It's kind of a pain though because we have a couple different size left panels that I'll have to handle.

    any other workarounds?

  13. daveyx commented on Mar 16, 2022

    @daveyx

    still an issue with angular 13, no margin is applied :-(

  14. walixxxq commented on Sep 16, 2025

    @walixxxq

    Still an issue with Angular 20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2area: material/sidenavregression

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions