Skip to content

Commit 3fdc672

Browse files
fritz-cclaydiffrient
authored andcommittedOct 31, 2016
Ensure aria-hidden on appElement is reset on unmount
1 parent e9fd43d commit 3fdc672

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

Diff for: ‎lib/components/Modal.js

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ var Modal = React.createClass({
6363
},
6464

6565
componentWillUnmount: function() {
66+
if (this.props.ariaHideApp) {
67+
ariaAppHider.show(this.props.appElement);
68+
}
69+
6670
ReactDOM.unmountComponentAtNode(this.node);
6771
document.body.removeChild(this.node);
6872
elementClass(document.body).remove('ReactModal__Body--open');

Diff for: ‎specs/Modal.spec.js

+12
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@ describe('Modal', function () {
207207
equal(document.body.className.indexOf('ReactModal__Body--open') !== -1, false);
208208
});
209209

210+
it('removes aria-hidden from appElement when unmounted without closing', function() {
211+
var el = document.createElement('div');
212+
var node = document.createElement('div');
213+
ReactDOM.render(React.createElement(Modal, {
214+
isOpen: true,
215+
appElement: el
216+
}), node);
217+
equal(el.getAttribute('aria-hidden'), 'true');
218+
ReactDOM.unmountComponentAtNode(node);
219+
equal(el.getAttribute('aria-hidden'), null);
220+
});
221+
210222
it('adds --after-open for animations', function() {
211223
var modal = renderModal({isOpen: true});
212224
var overlay = document.querySelector('.ReactModal__Overlay');

0 commit comments

Comments
 (0)