Skip to content

md-sidenav-container > div.mat-drawer-content unwanted margin #6958

Closed

Description

@mohitook

Bug, feature request, or proposal:

bug

What is the expected behavior?

There should be no unnecessary margin between the sidenav and the normal content.

What is the current behavior?

image

What are the steps to reproduce?

`

<button md-button routerLink="/">
  <md-icon>home</md-icon> 
      {{title}}</button>

  <!-- This fills the remaining space of the current row -->
  <span class="fill-remaining-space"></span>
  <div fxLayout="row" fxShow="false" fxShow.gt-sm>
      <button md-button routerLink="/products">Products</button>
      <button md-button routerLink="/dashboard">Dashboard</button>
  </div>
  <button md-button [md-menu-trigger-for]="menu" fxHide="false" fxHide.gt-sm>
   <md-icon>menu</md-icon>
  </button>

<md-menu x-position="before" #menu="mdMenu">
Products
Dashboard

menu
<!-- https://github.com/angular/material2/issues/1130 -->
<md-sidenav #sidenav class="app-sidenav"  mode="{{isMobileView?'over':'side'}}" opened="{{!isMobileView}}" disableClose="{{!isMobileView}}">
  <md-nav-list >
      <a md-list-item (click)="onLinkClick(sidenav)" >Majom Csimpánz Viziló</a>
      <a md-list-item href="page2.html">Page 2</a>
      <a md-list-item href="page3.html">Page 3</a>
  </md-nav-list>
</md-sidenav>
    
      <div class="app-content" style="padding-top:50px;"
      >
      <router-outlet></router-outlet>
    </div>

`

Please ignore the unnecessary codes.

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

newest

Is there anything else we should know?

After I resize the window and the sidenav goes to mobile mode, and back -> the unwanted margin is gone...

Activity

  1. willshowell commented on Sep 9, 2017

    @willshowell
    Contributor

    Can you reproduce in a plunker?

  2. mohitook commented on Sep 9, 2017

    @mohitook
    Author

    Plnkr :
    http://plnkr.co/edit/etkptgACMyo2Ty0SUyjX?p=preview
    Unfortunately I can't reproduce this behaviour.. but I have an idea:
    the problem is with this element:
    md-sidenav-container > div.mat-drawer-content
    here:
    image

    The margin-left is the property what is wrong. The interesting thing is that is is a counted value based on the sidenav's width. I don't know why but it adds + a few pixel to it what makes this issue..

  3. willshowell commented on Sep 10, 2017

    @willshowell
    Contributor

    This happens consistently? Can you show the styles and computed styles of the md-sidenav? Since you can't replicate in a fresh plunker, it sounds like you may have some overriding css somewhere else.

  4. sina-masoud-ansari commented on Sep 11, 2017

    @sina-masoud-ansari

    I'm having the same issue, sidenav-width 250px, margin-left on Safari 399px.

    Just fyi, a current work around in our project where the sidenav auto collapses for smaller screens:

    
    .sidenav-container .mat-drawer-content {
      margin-left: $sidenav-width !important;
    
    }
    
    @media (max-width: $md-thresh-min) {
    
        .sidenav-container .mat-drawer-content {
          margin-left: 0 !important;
        }
    
    }
    
    
  5. mohitook commented on Sep 11, 2017

    @mohitook
    Author

    so the problem is real. I won't use scss until I have no other option, but thanks for the workaround!

  6. dereekb commented on Sep 12, 2017

    @dereekb
    Contributor

    I've had this issue on macOS Safari only, and haven't seen it appear in Chrome. Happens somewhat consistently, but not always.

    screen shot 2017-09-12 at 12 41 16 pm

    The sidenav is also responsive, and it only recently started happening. Might be somewhat related to #6743.

  7. josephperrott commented on Sep 27, 2017

    @josephperrott
    Member

    It looks like the logic controlling this was updated in #6712

    If you are still seeing this issue please provide a reproduction plunker/stackblitz for us to investigate.

  8. added
    cannot reproduce
    on Sep 27, 2017
  9. dereekb commented on Sep 27, 2017

    @dereekb
    Contributor

    I’ll try and reproduce it when I get a chance, but it only occurred in Safari. I’ll try it on both Sierra and High Sierra.

  10. functionportal commented on Oct 6, 2017

    @functionportal

    In the release 2.0.0-beta.12 the right margin is randomly miscalculated for mat-sidenav-content when sidenav in in side mode. If the sidenav mode is dynamically switched between over and side, the problem randomly resolves itself. There must be some kind of timing issue in calculating the mat-sidenav-content right margin.

  11. karan-kang commented on Oct 20, 2017

    @karan-kang

    This issue is reproducible for me.

  12. afarbman commented on Jan 10, 2018

    @afarbman

    having the same issue

  13. removed
    cannot reproduce
    on Jan 17, 2018
  14. mmalerba commented on Jan 17, 2018

    @mmalerba
    Contributor

    This sounds like it might be related to #5698 which I filed a chrome bug for: https://bugs.chromium.org/p/chromium/issues/detail?id=787628

  15. added
    P3
    on Jan 25, 2018
  16. mmalerba commented on Jan 27, 2018

    @mmalerba
    Contributor

    Those of you experiencing issues, have you tried the autosize option? does it help?

  17. tpeyrard commented on Feb 5, 2018

    @tpeyrard

    @mmalerba it's worse because it makes the problem appear 100% of time.

    If I open the sidenav, it adds 215px margin-left, that I don't want. However, if I load another component while the sidenav is open, the 215px are correctly applied (they're applied from the left of the screen, not from the right of the sidenav.

    Tried on Firefox 58.

  18. mmalerba commented on Feb 5, 2018

    @mmalerba
    Contributor

    @tpeyrard can you provide a stackblitz repro? here's our template: https://stackblitz.com/edit/angular-material2-issue

  19. ishan123456789 commented on Feb 13, 2018

    @ishan123456789

    Removing all the animations helped me fix the issue.Hope this helps someone.

  20. mmalerba commented on Feb 16, 2018

    @mmalerba
    Contributor

    I'm assuming this is the same issue as #9837, check out the plunker I posted on that issue for a workaround

  21. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  22. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions