Skip to content

Commit

Permalink
[fixed] Modal.removePortal not called when using closeTimeoutMS
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Nichols authored and diasbruno committed Jun 29, 2017
1 parent f386aa4 commit f47e79d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ describe('State', () => {
expect(document.querySelector('.ReactModalPortal')).toNotExist();
});

it('removes the portal node after closeTimeoutMS', done => {
const closeTimeoutMS = 100;
renderModal({ isOpen: true, closeTimeoutMS }, 'hello');

function checkDOM(count) {
const portal = document.querySelectorAll('.ReactModalPortal');
expect(portal.length).toBe(count);
}

unmountModal();

// content is still mounted after modal is gone
checkDOM(1);

setTimeout(() => {
// content is unmounted after specified timeout
checkDOM(0);
done();
}, closeTimeoutMS);
});

it('focuses the modal content', () => {
const modal = renderModal({ isOpen: true }, null);
expect(document.activeElement).toBe(mcontent(modal));
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default class Modal extends Component {
this.portal.closeWithTimeout();
}

setTimeout(() => this.removePortal, closesAt - now);
setTimeout(this.removePortal, closesAt - now);
} else {
this.removePortal();
}
Expand Down

0 comments on commit f47e79d

Please sign in to comment.