Skip to content

Commit

Permalink
Merge pull request tajo#40 from theaqua/patch-2
Browse files Browse the repository at this point in the history
fix: use cloneElement instead of div.openByClickOn
  • Loading branch information
tajo committed Feb 2, 2016
2 parents b313e70 + 9d594d8 commit 0e48366
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class Portal extends React.Component {

render() {
if (this.props.openByClickOn) {
return <div className="openByClickOn" onClick={this.handleWrapperClick}>{this.props.openByClickOn}</div>;
return React.cloneElement(this.props.openByClickOn, {onClick: this.handleWrapperClick});
} else {
return null;
}
Expand Down
5 changes: 3 additions & 2 deletions test/portal_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ describe('react-portal', () => {
});

it('should render the props.openByClickOn element', () => {
const openByClickOn = <button>button</button>;
const text = `open by click on me`;
const openByClickOn = <button>${text}</button>;
const wrapper = mount(<Portal openByClickOn={openByClickOn}><p>Hi</p></Portal>);
assert(wrapper.contains(openByClickOn));
assert(wrapper.text(text));
});

it('should open portal when clicking openByClickOn element', () => {
Expand Down

0 comments on commit 0e48366

Please sign in to comment.