Skip to content

Commit

Permalink
Merge pull request reactjs#94 from apprennet/remove-body-class-unmount
Browse files Browse the repository at this point in the history
[fixed] Remove ReactModal__Body--open class when unmounting Modal
  • Loading branch information
claydiffrient committed Mar 28, 2016
2 parents fe46c63 + cb53bca commit f9871c6
Show file tree
Hide file tree
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
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit f9871c6

Please sign in to comment.