Hide dropdown menu on click on item or click outside

Is there a way to hide a React InstantSearch menu when clicking outside of it or in an item?

The only related post about it I’ve found is this: Is there a way to hide the search results when clicking on a search result? · Issue #1756 · algolia/instantsearch.js · GitHub
but it has no example of how to achieve it.