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
  • Loading branch information
jasonblanchard committed Mar 28, 2016
1 parent fe46c63 commit cb53bca
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 cb53bca

Please sign in to comment.