Clicking on a trigger button outside a portal doesn't work
ranneyd opened this issue · 1 comments
ranneyd commented
Take the example in the docs, but remove the conditional rendering (so it's always showing). The user would expect to click on this button to "toggle" the portalized component. Clicking on it closes the modal (because it's outside), but the click event on the button still triggers, meaning the modal reopens, meaning it doesn't close when you click on the button.
I tried putting onClick={isOpen ? closePortal : openPortal}
. The problem is since the outside click fires first, isOpen
is already false. I can't think of a pure solution to this (something that doesn't involve the parent's state or redux).
tajo commented
Yea, I don't how to solve this in an elegant way either.