Skip to content

Commit

Permalink
[chore] Return null for portal when modal is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ives van Hoorne authored and diasbruno committed Jul 2, 2017
1 parent 55920f9 commit e56c414
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ describe('State', () => {
expect(ReactDOM.findDOMNode(mcontent(modal))).toNotExist();
});

it('doesn\'t render the portal if modal is closed', () => {
const modal = renderModal({}, 'hello');
expect(ReactDOM.findDOMNode(modal.portal)).toNotExist();
})

it('has default props', () => {
const node = document.createElement('div');
Modal.setAppElement(document.createElement('div'));
Expand Down
2 changes: 1 addition & 1 deletion src/components/ModalPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export default class ModalPortal extends Component {
const contentStyles = className ? {} : defaultStyles.content;
const overlayStyles = overlayClassName ? {} : defaultStyles.overlay;

return this.shouldBeClosed() ? <div /> : (
return this.shouldBeClosed() ? null : (
<div
ref={this.setOverlayRef}
className={this.buildClassName('overlay', overlayClassName)}
Expand Down

0 comments on commit e56c414

Please sign in to comment.