Topic: Navbar dropdown menus not closing at click
Actual behavior Clicking on navbar dropdown menus the menu don't collapse/close as expected. This happens on Windows 10 pro but the behavior seems normal on Mac OS 10.11 - 15.
I tested with Firefox 70.00.1 Build Official 64 bit and Chrome 78.0.3904.87 Build Official 64 bit.
Resources (screenshots, code snippets etc.) This in a screencast gif: https://giphy.com/gifs/L3WtMOUyXPrL1F4LD7
You can see the behavior directly on the documentation page: https://mdbootstrap.com/docs/jquery/navigation/navbar/ and in some elements in https://mdbootstrap.com/docs/jquery/components/dropdowns/.
See also: https://mdbootstrap.com/support/jquery/navbar-dropdown-menus-not-closing/ (reporting similar problem).
gianlucagiacometti
pro answered a year ago
Workaround:
$(document).ready(function() {
$('body').on('mouseup', function (e) {
if (!$(e.target).hasClass("dropdown-menu")) {
$(".dropdown-menu").each(function () {
$(this).removeClass("show");
});
}
});
});
Resolved
- User: Free
- Premium support: No
- Technology: jQuery
- MDB Version: 4.8.11
- Device: Desktop
- Browser: Firefox, Chrome
- OS: Windows 10
- Provided sample code: No
- Provided link: Yes