Solution:
What we have done in the past is added an HTML snippet with JavaScript code to cause the menu to collapse when clicked outside of that element. Note that if you use this method, the menu will close by clicking on anything outside of the menu, such as a popup that has been pulled in from the menu. Here is some code from Stack Overflow that can help you out.
$('body').click(function(event){
// check if the clicked element is a descendent of navigation
if ($(event.target).closest('.navigation').length) { // replace .navigation with the class of the menu bar
return; //do nothing if event target is within the navigation
} else {
// do something if the event target is outside the navigation
$('.navigation').collapse() // replace .navigation with the class of the menu bar
}
});
Continuation..