react, react-bootstrap – MenuItem won’t hide the menu on click

React and react-bootstrap provide an easy an clean way to build an application interface. However, when using the MenuItem in combination with the opening of a modal windows, if clicked, the dropdown menu does not close, but stays open below the backdrop.

I found some solutions based on jQuery, but the cleanest one was adding in the modal opening command the following code:

document.dispatchEvent(new MouseEvent('click'));Code language: JavaScript (javascript)

Source: