'mat-sidenav' inside component and not directly in 'mat-sidenav-container' does not resize to 100%
See original GitHub issueBug, 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
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:
- Created 6 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
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.
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.