From 3fdc67290a54bb600c410882a0edc032d74b82d5 Mon Sep 17 00:00:00 2001 From: fritz-c Date: Mon, 24 Oct 2016 10:52:32 +0900 Subject: [PATCH] Ensure aria-hidden on appElement is reset on unmount --- lib/components/Modal.js | 4 ++++ specs/Modal.spec.js | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/components/Modal.js b/lib/components/Modal.js index 5a7c900b..45f7e34d 100644 --- a/lib/components/Modal.js +++ b/lib/components/Modal.js @@ -63,6 +63,10 @@ var Modal = React.createClass({ }, componentWillUnmount: function() { + if (this.props.ariaHideApp) { + ariaAppHider.show(this.props.appElement); + } + ReactDOM.unmountComponentAtNode(this.node); document.body.removeChild(this.node); elementClass(document.body).remove('ReactModal__Body--open'); diff --git a/specs/Modal.spec.js b/specs/Modal.spec.js index eee8df08..7a9a85a7 100644 --- a/specs/Modal.spec.js +++ b/specs/Modal.spec.js @@ -207,6 +207,18 @@ describe('Modal', function () { equal(document.body.className.indexOf('ReactModal__Body--open') !== -1, false); }); + it('removes aria-hidden from appElement when unmounted without closing', function() { + var el = document.createElement('div'); + var node = document.createElement('div'); + ReactDOM.render(React.createElement(Modal, { + isOpen: true, + appElement: el + }), node); + equal(el.getAttribute('aria-hidden'), 'true'); + ReactDOM.unmountComponentAtNode(node); + equal(el.getAttribute('aria-hidden'), null); + }); + it('adds --after-open for animations', function() { var modal = renderModal({isOpen: true}); var overlay = document.querySelector('.ReactModal__Overlay');