Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: NavbaR DROPDOWN not closing after click

Alberto pro asked 7 years ago


hello, I have this code. When the navbar is collapsed clicking on a dropdown works and the dropdown closes. If the navbar is not collapsed clicking on the dropdown menu items works but the menu does not closes. Of I put a click event listener (click)="hideNavbar(navbar)" , it closes it and then it reopens by itself. It used to work until a day or two ago. Please fix or provide instructions <mdb-navbar SideClass="navbar navbar-expand-lg navbar-dark navbar-maroon fixed-top" #navbar [containerInside]="false" ><!-- temporarily removed due to bug in MDB --> <logo> <logo><aclass="navbar-brand"href="#">Navbar</a></logo> </logo> <!-- End Logo --> <links> <ulclass="navbar-nav "> <liclass="nav-item dropdown"dropdown> <adropdownTogglemdbRippleRadiustype="button"class="nav-link dropdown-toggle waves-light"mdbRippleRadius> Basic dropdown<span class="caret"></span></a> <div *dropdownMenuclass="dropdown-menu dropdown dropdown-primary"role="menu"> <aclass="dropdown-item waves-light"mdbRippleRadius [routerLink]="['/home']"mdbPageScrollhref="#team-section">Action</a> <aclass="dropdown-item waves-light"mdbRippleRadiushref="#">Another action</a> <aclass="dropdown-item waves-light"mdbRippleRadiushref="#">Something else here</a> <divclass="divider dropdown-divider"></div> <aclass="dropdown-item waves-light"mdbRippleRadiushref="#">Separated link</a> </div> </li> </ul> </links> </mdb-navbar>

Damian Gemza staff answered 7 years ago


Dear Alberto, please read our documentation carefully. We have described situation, where navbar links doesn't hide after click in mobile view. You have to add
[routerLink]="['/']"
to every link in your's navbar/dropdown. Link to our documentation: https://mdbootstrap.com/angular/components/navbars/ Best Regards, Damian

Alberto pro commented 7 years ago

Damian, it works in mobile view. It's in desktop view that it doesnt. And I did add [routerlink]="['/mylink']" to all without success

Damian Gemza staff commented 7 years ago

Dropdown doesn't hide in desktop ? If yes, please try to delete from it directive mdbRippleRadius.

Alberto pro commented 7 years ago

That was it. mdbRippleRadius. Now it works but doesn't look like material withot the ripple...

Alberto pro commented 7 years ago

Also another thing that doesn't work anymore is hide(); I have a listener on window scroll to close the dropdowns if the user scrolls and now it doesn't work. If I call the navbar hide method it hides it and then immediately it reappears. I tried closeNavbarOnClick but it doesn't do anything. This code used to work // Hack to close the navbar if window is scrolled away @HostListener("window:scroll", []) onWindowScroll() { if (this._navBar.shown) { this._navBar.hide();} }

Damian Gemza staff commented 7 years ago

Yes, Alberto, i know about that problem. We're working about fixing this case. In next releases we'll put fix that allows you to use mdbRippleRadius directive and hide properly dropdowns after clicking somewhere. Best Regards, Damian

osoverflow pro commented 6 years ago

I have the same problem. On desktop with mdbRippleRadius it does not close, but without that mdbRippleRadius it closes.

Damian Gemza staff commented 6 years ago

Dear osoverflow, Could you please tell me, which version of MDB do you use in your project? This problem was fixed in 5.2.1 release of MDB Angular. If you're using something below that version, please upgrade it. Best Regards, Damian

osoverflow pro commented 6 years ago

It is this: "angular-bootstrap-md": "^5.2.2",

Damian Gemza staff commented 6 years ago

And for 5.2.2 mdbRippleRadius directive doesn't work? We've tested this few times and it was working perfectly. Could you show me your code?

osoverflow pro commented 6 years ago

<!-- Dropdown --> <li class="nav-item dropdown btn-group" dropdown *ngIf="auth.isAuthenticated()|async"> <a dropdownToggle mdbRippleRadius type="button" class="nav-link dropdown-toggle waves-light"> <i class="fa fa-user"></i> Mi Cuenta </a> <div *dropdownMenu class="dropdown dropdown-menu dropdown-primary dropdown-menu-right" role="menu"> <a class="dropdown-item waves-light" routerLink="/support"><i class="fa fa-question"></i> Soporte</a> <a class="dropdown-item waves-light" routerLink="/tutorial"><i class="fa fa-product-hunt"></i> Tutorial</a> <a class="dropdown-item waves-light" routerLink="/history"><i class="fa fa-history"></i> Historial</a> <div class="divider dropdown-divider"></div> <a class="dropdown-item waves-light" (click)="logout()"><i class="fa fa-sign-out"></i> Salir</a> </div> </li>

osoverflow pro commented 6 years ago

I removed the mdbRippleRadius on all the links because the problem

Damian Gemza staff commented 6 years ago

I've added to your code mdbRippleRadius in every place. Tested this on MDB Angular Free 5.2.1 and on MDB Angular Pro my developers version for next update, and for me, everything is working fine. I've got two dropdowns. When i open one, and click to another, first dropdown is closing and second is showing. So I can't see any problem there. Are you sure, that you're using right version of our MDB? Which version do you use? Free or Pro? And in which way did you installed it ?

osoverflow pro commented 6 years ago

I'm using the free version while I get access to the pro version. I installed following the instructions npm i angular-bootstrap-md --save Found in: https://mdbootstrap.com/angular/5min-quickstart/

Damian Gemza staff commented 6 years ago

Could you please send me your project without node_modules folder at d.gemza@mdbootstrap.com ?


Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags