Skip to content

Commit

Permalink
Ensure aria-hidden on appElement is reset on unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
fritz-c authored and claydiffrient committed Oct 31, 2016
1 parent e9fd43d commit 3fdc672
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/components/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
12 changes: 12 additions & 0 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 3fdc672

Please sign in to comment.