Flyout menu using react context re-opens when closing it with its button
I am coding a FlyoutManager from which I can toggle every flyout menus in react app. I am trying to set the property to close when clicking outside. I found on another stackoverflow question that my clicking-outside function is triggered when I click the button to close it so it re-opens the flyout menu because it toggles the menu state twice.
How to Ensure State Consistency When Using React Context and Asynchronous setState?
I want to maintain the filter values, which are key value pairs in a global context to support app wide state.