diff --git a/lib/portal.js b/lib/portal.js index 6f06fb3..b2a00c8 100644 --- a/lib/portal.js +++ b/lib/portal.js @@ -89,7 +89,7 @@ export default class Portal extends React.Component { render() { if (this.props.openByClickOn) { - return
{this.props.openByClickOn}
; + return React.cloneElement(this.props.openByClickOn, {onClick: this.handleWrapperClick}); } else { return null; } diff --git a/test/portal_spec.js b/test/portal_spec.js index 9a1db5e..72b29c3 100644 --- a/test/portal_spec.js +++ b/test/portal_spec.js @@ -165,9 +165,10 @@ describe('react-portal', () => { }); it('should render the props.openByClickOn element', () => { - const openByClickOn = ; + const text = `open by click on me`; + const openByClickOn = ; const wrapper = mount(

Hi

); - assert(wrapper.contains(openByClickOn)); + assert(wrapper.text(text)); }); it('should open portal when clicking openByClickOn element', () => {