Dealing with a similar issue recently, I decided to implement mouseenter and mouseleave events.
$( ".menu-open" )
// unnecessary
.mouseenter(function() {
$( this ).show();
})
// important to hide the menu when user leaves it
.mouseleave(function() {
$( this ).hide();
});
With the above code, the menu will automatically hide once the user moves the cursor away from it. This provides users with a seamless experience where they don't have to worry about manually closing the menu if they no longer need it. It would feel awkward if the menu remained open until the user clicked on it again to close.
I can relate to your example from here.
Alternatively, you could also consider using a scroll event that triggers the menu to hide once the user scrolls down past a certain point.