Skip to content

Commit 12ecf65

Browse files
[fixed] Remove ReactModal__Body--open class when unmounting Modal
1 parent 1a0a069 commit 12ecf65

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/components/Modal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var Modal = module.exports = React.createClass({
5454
componentWillUnmount: function() {
5555
ReactDOM.unmountComponentAtNode(this.node);
5656
document.body.removeChild(this.node);
57+
elementClass(document.body).remove('ReactModal__Body--open');
5758
},
5859

5960
renderPortal: function(props) {

specs/Modal.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ describe('Modal', function () {
136136
unmountModal();
137137
});
138138

139+
it('removes class from body when unmounted without closing', function() {
140+
modal = renderModal({isOpen: true});
141+
equal(document.body.className.indexOf('ReactModal__Body--open') !== -1, true);
142+
unmountModal();
143+
equal(document.body.className.indexOf('ReactModal__Body--open') !== -1, false);
144+
});
145+
139146
it('adds --after-open for animations', function() {
140147
var modal = renderModal({isOpen: true});
141148
var overlay = document.querySelector('.ReactModal__Overlay');

0 commit comments

Comments
 (0)