Topic: sidenav close on click link on small screen

marc parthoens free asked 5 years ago

We use Double Navigation with fixed SideNav & non-fixed Navbar

The expected behavior:

Sidenav is hidden (small screens)

Opened by clicking on hamburger button

Hide sidenav automatically when clicking on a link

We have tried (click)="sidenav.hide()"

The issue is that that click also hide sidenav on larger screen when it always supposed to be open.

Damian Gemza staff answered 5 years ago

Dear Marc,

Please use the below code to achieve your desired functionality:


<mdb-accordion-item class="no-collase" (click)="hideSidenavAfterClick()">
          <mdb-accordion-item-head mdbWavesEffect><i
            class="far fa-gem"></i> Simple link 2


@ViewChild('sidenav') sidenav: SidenavComponent;
  hideSidenavAfterClick() {
    if (window.innerWidth <= 768) {

elemech premium commented 4 years ago

import { SidenavComponent } from 'ng-uikit-pro-standard';

marc parthoens free answered 5 years ago

Great. Thanks. I try this. Should work

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 7.4.2
  • Device: small screens
  • Browser: all
  • OS: windows 10
  • Provided sample code: No
  • Provided link: No