materialize icon indicating copy to clipboard operation
materialize copied to clipboard

Navbar with mobile collapse button does not initialize sidenav without container

Open serkandurusoy opened this issue 11 years ago • 6 comments

This, taken from the starter example works:

<nav class="light-blue lighten-1" role="navigation">
  <div class="container">
    <div class="nav-wrapper"><a id="logo-container" href="#" class="brand-logo">Logo</a>
      <ul id="nav-mobile" class="right side-nav">
        <li><a href="#">Navbar Link</a></li>
      </ul><a href="#" data-activates="nav-mobile" class="button-collapse"><i class="mdi-navigation-menu"></i></a>
    </div>
  </div>
</nav>

Whereas this does not work:

<nav class="light-blue lighten-1" role="navigation">
  <div class="nav-wrapper"><a id="logo-container" href="#" class="brand-logo">Logo</a>
    <ul id="nav-mobile" class="right side-nav">
      <li><a href="#">Navbar Link</a></li>
    </ul><a href="#" data-activates="nav-mobile" class="button-collapse"><i class="mdi-navigation-menu"></i></a>
  </div>
</nav>

Tried it with the example provided on the website, and that exact example does not work unless the nav-wrapper div is also wrapped within a container or seemingly, adding the class container to the nav-wrapper

This may sound alright, but on an site/app where fluid design is used, constraining the width of the navbar elements to a 992px fixed area is not viable.

Also, the collapsing of the navbar right menu seems to happen very early (again, 992px). Normally, one should expect the menu to collapse somewhere around a table portrait viewport width. At least this should somehow be configurable.

serkandurusoy avatar Jan 23 '15 03:01 serkandurusoy

The two pieces of code you posted are the same

Dogfalo avatar Jan 23 '15 17:01 Dogfalo

Sorry, trigger happy fingers here.

I fixed it. Now you can see two different examples, the first of which works whereas the second does not.

serkandurusoy avatar Jan 23 '15 17:01 serkandurusoy

Investigated further.

It seems, the toggling element such as has to be somewhere within a .container for it to be able to toggle the sidenav.

So the problem is not initialization, rather the activating element not being able to initiate a toggle of the sidenav it activates unless surrounded by an element with a container class.

serkandurusoy avatar Jan 26 '15 17:01 serkandurusoy

Experimenting further,

It now seems, if I right align the toggle, it works again.

It appears that the problem is, if the toggle switch is placed anywhere on the page that the sidenav would have covered up if it were open, it just does not toggle.

So placing the toggle aside kind of helps avoid the problem.

Therefore, I can't decide if this should be filed as a bug or not, but I believe there is room here for some enhancement.

serkandurusoy avatar Jan 26 '15 17:01 serkandurusoy

Thanks, finally I decided to change the way my navigation works but I'll keep that in mind!

KBoisvert avatar Jan 29 '15 18:01 KBoisvert

Fixed in v0.95.1

Dogfalo avatar Feb 08 '15 23:02 Dogfalo