Skip to content

Commit

Permalink
[fixed] added finalisation for the Modal when it was unbound from the…
Browse files Browse the repository at this point in the history
… tree
  • Loading branch information
zerkms committed Jul 30, 2015
1 parent 23f3e0c commit a4ce7e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ const Modal = React.createClass({
}
},

componentWillUnmount() {
if (this.props.show) {
this.onHide();
}
},

onShow() {
const doc = domUtils.ownerDocument(this);
const win = domUtils.ownerWindow(this);
Expand Down
16 changes: 16 additions & 0 deletions test/ModalSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ describe('Modal', function () {
, mountPoint);
});

it('Should unbind listeners when unmounted', function() {
render(
<div>
<Modal show onHide={() => null} animation={false}>
<strong>Foo bar</strong>
</Modal>
</div>
, mountPoint);

assert.include(document.body.className, 'modal-open');

render(<div />, mountPoint);

assert.notInclude(document.body.className, 'modal-open');
});

describe('Focused state', function () {
let focusableContainer = null;

Expand Down

0 comments on commit a4ce7e1

Please sign in to comment.