tajo/react-portal

Unable to close portal on a specific node

bmpinto opened this issue · 1 comments

I'm successfully creating a portal to a specific node (<Portal node={ ... }>), but when I need to close that portal, I get an error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

This error points to line 39 of LegacyPortal.js: document.body.removeChild(this.props.node);

It makes sense, since that specific node is not a direct child of body, so he can't remove it.
Shouldn't we find that specific node and remove its content?

What am I missing?

tajo commented

It's a bug in the LegacyPortal. We should not remove custom node and match this behavior: https://github.com/tajo/react-portal/blob/master/src/Portal.js#L7-L11

Do you want to create a PR?