From cb53bcaa8eb8977bae8e264645e96ee107c769f1 Mon Sep 17 00:00:00 2001 From: Jason Blanchard Date: Mon, 2 Nov 2015 11:36:07 -0500 Subject: [PATCH] [fixed] Remove ReactModal__Body--open class when unmounting Modal --- lib/components/Modal.js | 1 + specs/Modal.spec.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/components/Modal.js b/lib/components/Modal.js index 2b80d7cc..bb002983 100644 --- a/lib/components/Modal.js +++ b/lib/components/Modal.js @@ -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) { diff --git a/specs/Modal.spec.js b/specs/Modal.spec.js index 4162bfd4..53670799 100644 --- a/specs/Modal.spec.js +++ b/specs/Modal.spec.js @@ -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');