question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'mat-sidenav' inside component and not directly in 'mat-sidenav-container' does not resize to 100%

See original GitHub issue

Bug, feature request, or proposal:

When ‘mat-sidenav’ is wrapped in component under ‘mat-sidenav-container’ then height 100% is not calculated correctly anymore but If ‘mat-sidenav’ element is directly under ‘mat-sidenav-container’ it is ok.

Basically: following breaks height 100%

<mat-sidenav-container>
  <app-sidenav></app-sidenav>

  <div class="content">
    <router-outlet></router-outlet>
  </div>
</mat-sidenav-container>

but: would work:

<mat-sidenav-container>
  <mat-sidenav mode="side" opened="true" class="sidenav">
    <mat-nav-list>
      <mat-list-item *ngFor="let link of links">
        <a matLine routerLink="/{{link}}">{{ link }}</a>
      </mat-list-item>
    </mat-nav-list>
  </mat-sidenav>

  <div class="content">
    <router-outlet></router-outlet>
  </div>
</mat-sidenav-container>

What is the expected behavior?

height should be 100% for sidenav not be stuck with window initial size

What is the current behavior?

height is stuck to size of window Broken

But if ‘mat-sidenav’ is in html directly under ‘mat-sidenav-container’ every thing is ok

What are the steps to reproduce?

Example project: https://github.com/aldas/angular-material2-sidenav-issue-example

Sidenav OK commit: https://github.com/aldas/angular-material2-sidenav-issue-example/commit/ced15fbff94f00099372000b00350d2279bab67b

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

modularise application menu inside sidenav setup.

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

    "@angular/core": "^5.0.0",
    "@angular/material": "^5.0.0-rc0",

...
    "typescript": "~2.4.2"
    "@angular/cli": "1.5.0",

Chrome latest, FF latest

Is there anything else we should know?

nope

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
colmbencommented, Mar 28, 2018

Just wasted an hour on this, you might to mention in the doco page that <mat-sidenav> wouldn’t work if it pushed down to a custom component.

https://material.angular.io/components/sidenav/overview

4reactions
aldascommented, Nov 9, 2017

Atm in my real project I just pulled ‘mat-sidenav’ up to parent component and modularized just content of ‘mat-sidenav’ into its own component ‘app-sidenav’

so: this works fine.

<mat-sidenav-container>
  <mat-sidenav mode="side" opened="true" class="sidenav">
    <app-sidenav></app-sidenav>
  </mat-sidenav>
  <div class="content">
    <router-outlet></router-outlet>
  </div>
</mat-sidenav-container>

I’m quite new to Angular so I did not know to think about that (some) components/directives have strict parent-child relation and there can not be intermediate elements/components between.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Collapsable mat-sidenav menu rezise content not working
I used ngClass and a boolean controlling both mat-sidenav width property and mat-sidenav-content margin-left property . Here is a stackblitz ...
Read more >
Fullscreen the Material Sidenav Container - Ole Ersoy - Medium
We want our mat-sidenav-container to cover the entire screen. ... markup that can be used inside a custom component replacing mat-sidenav-container :
Read more >
How does the footer work in Angular material? - eduCBA
In Angular we can create a footer by making use of 'mat-sidenav-container' it is a container inside which we can place all our...
Read more >
Angular Material Mobile App with Capacitor - Devdactic
In this tutorial we will go through all the steps of setting up an Angular project and integrating Angular Material.
Read more >
Create a responsive sidebar menu with Angular Material
But most of the components that we have are not really responsive. ... mat-sidenav-container { height: calc(100vh - 65px); }.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found