Skip to content

Commit f9871c6

Browse files
committed
Merge pull request #94 from apprennet/remove-body-class-unmount
[fixed] Remove ReactModal__Body--open class when unmounting Modal
2 parents fe46c63 + cb53bca commit f9871c6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Diff for: lib/components/Modal.js

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var Modal = module.exports = React.createClass({
5959
componentWillUnmount: function() {
6060
ReactDOM.unmountComponentAtNode(this.node);
6161
AppElement.removeChild(this.node);
62+
elementClass(document.body).remove('ReactModal__Body--open');
6263
},
6364

6465
renderPortal: function(props) {

Diff for: specs/Modal.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ describe('Modal', function () {
175175
unmountModal();
176176
});
177177

178+
it('removes class from body when unmounted without closing', function() {
179+
var modal = renderModal({isOpen: true});
180+
equal(document.body.className.indexOf('ReactModal__Body--open') !== -1, true);
181+
unmountModal();
182+
equal(document.body.className.indexOf('ReactModal__Body--open') !== -1, false);
183+
});
184+
178185
it('adds --after-open for animations', function() {
179186
var modal = renderModal({isOpen: true});
180187
var overlay = document.querySelector('.ReactModal__Overlay');

0 commit comments

Comments
 (0)