Skip to content

Commit

Permalink
[fixed] Remove ReactModal__Body--open class when unmounting Modal
Browse files Browse the repository at this point in the history
jasonblanchard committed Mar 28, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fe46c63 commit cb53bca
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/components/Modal.js
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ var Modal = module.exports = React.createClass({
componentWillUnmount: function() {
ReactDOM.unmountComponentAtNode(this.node);
AppElement.removeChild(this.node);
elementClass(document.body).remove('ReactModal__Body--open');
},

renderPortal: function(props) {
7 changes: 7 additions & 0 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
@@ -175,6 +175,13 @@ describe('Modal', function () {
unmountModal();
});

it('removes class from body when unmounted without closing', function() {
var modal = renderModal({isOpen: true});
equal(document.body.className.indexOf('ReactModal__Body--open') !== -1, true);
unmountModal();
equal(document.body.className.indexOf('ReactModal__Body--open') !== -1, false);
});

it('adds --after-open for animations', function() {
var modal = renderModal({isOpen: true});
var overlay = document.querySelector('.ReactModal__Overlay');

0 comments on commit cb53bca

Please sign in to comment.