Components: [Sidenav] Issue when container and sidenav in different components

Created on 12 Dec 2017  路  4Comments  路  Source: angular/components

Bug, feature request, or proposal:

I have the template like this:
<mat-sidenav-container class="sidenav-container">
<my-component></my-component>
...
</mat-sidenav-container>

<my-component> is:
<mat-sidenav #leftSidenav class="sidenav" mode="side" [opened]="true">
...
</mat-sidenav>

When I have my sidenav in two components like this, the mode "side" is not working anymore. The mode switch to "over".
When I have all in the same component, it's working.

I think it's due to a another tag between and and it break the css rules.

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

Angular Material 5.0.1

P4 feature

Most helpful comment

This use case is not currently supported, instead you would do something like this:

<mat-sidenav-container>
  <mat-sidenav>
    <my-sidenav></my-sidenav>
  </mat-sidenav>
  <mat-sidenav-content>
    <my-content></my-content>
  </mat-sidenav-content>
</mat-sidenav-container>

All 4 comments

This use case is not currently supported, instead you would do something like this:

<mat-sidenav-container>
  <mat-sidenav>
    <my-sidenav></my-sidenav>
  </mat-sidenav>
  <mat-sidenav-content>
    <my-content></my-content>
  </mat-sidenav-content>
</mat-sidenav-container>

I would also love to see this split-up!

Would also love to see all sidenav 'modes' working when splitting out into different components via transclusion/content-projection.

Currently only 'over' works...

Repro on stackblitz: https://stackblitz.com/edit/angular-material-sidenav-mode

Mode is set to 'push' while showing behaviour of 'over' in /app/components/sidenav.component

The sidenav split out approach is also used by the ngrx team in their example app: https://github.com/ngrx/platform/tree/v4.1.1/example-app

You can reproduce the issue in the example-app by trying to set the mode to 'push' or 'side'.

According to official docs: "The must be placed as an immediate child of the ."

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vanor89 picture vanor89  路  3Comments

RoxKilly picture RoxKilly  路  3Comments

jelbourn picture jelbourn  路  3Comments

alanpurple picture alanpurple  路  3Comments

Miiekeee picture Miiekeee  路  3Comments