It would be great to support the case of having our component rendered inside a portal located in a new browser window.
With react portals, we can create a new browser window and render our components there. For example using react-new-window library (https://github.com/rmariuzzo/react-new-window).
I am using this in my application to being able of split my application in several small separated browser windows.
The problem here is that now the react-cool-onclickoutside library is always attaching the event listeners to the document, and when we are creating a new window and rendering our components there via portals, this premise is not valid.
So, in this new scenario, if you click outside the target component but inside your new window, that is not under the main document the listeners are not triggered.
I can try to provide a simple demo example to show you the use case if necessary.
What I propose is to have an optional parameter to pass a reference of the element that you want to use as root to attach the events (customRootRef or something like that) to be used instead of document.
This way it would be possible to pass a reference to the higher level component rendered in this new window. So if I click outside the target component but inside the window where this component is rendered, the react-cool-clickoutside ill accomplish its purpose.