Skip to content

Commit 84cb2c9

Browse files
author
Mark Funk
committed
Updating OverlayMixin to allow for a null overlay that will not be rendered
1 parent 0793e12 commit 84cb2c9

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/OverlayMixin.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ module.exports = {
4949
this._mountOverlayTarget();
5050
}
5151

52+
var overlay = this.renderOverlay();
53+
5254
// Save reference to help testing
53-
this._overlayInstance = React.render(this.renderOverlay(), this._overlayTarget);
55+
if (overlay !== null) {
56+
this._overlayInstance = React.render(this.renderOverlay(), this._overlayTarget);
57+
}
5458
},
5559

5660
_unrenderOverlay: function () {
@@ -63,7 +67,11 @@ module.exports = {
6367
throw new Error('getOverlayDOMNode(): A component must be mounted to have a DOM node.');
6468
}
6569

66-
return this._overlayInstance.getDOMNode();
70+
if (this._overlayInstance) {
71+
return this._overlayInstance.getDOMNode();
72+
}
73+
74+
return null;
6775
},
6876

6977
getContainerDOMNode: function () {

test/OverlayMixinSpec.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,18 @@ describe('OverlayMixin', function () {
4848

4949
assert.equal(instance.getDOMNode().querySelectorAll('#test1').length, 1);
5050
});
51+
52+
it('Should not render a null overlay', function() {
53+
var Container = React.createClass({
54+
render: function() {
55+
return <Overlay ref='overlay' container={this} overlay={null} />;
56+
}
57+
});
58+
59+
instance = ReactTestUtils.renderIntoDocument(
60+
<Container />
61+
);
62+
63+
assert.equal(instance.refs.overlay.getOverlayDOMNode(), null);
64+
});
5165
});

0 commit comments

Comments
 (0)