diff --git a/specs/Modal.events.spec.js b/specs/Modal.events.spec.js index 5565f472..bc02c9f7 100644 --- a/specs/Modal.events.spec.js +++ b/specs/Modal.events.spec.js @@ -25,6 +25,16 @@ export default () => { afterOpenCallback.called.should.be.ok(); }); + it("should call onAfterOpen with overlay and content references", () => { + const afterOpenCallback = sinon.spy(); + const modal = renderModal({ isOpen: true, onAfterOpen: afterOpenCallback }); + + sinon.assert.calledWith(afterOpenCallback, { + overlayEl: modal.portal.overlay, + contentEl: modal.portal.content + }); + }); + it("should trigger the onAfterClose callback", () => { const onAfterCloseCallback = sinon.spy(); const modal = renderModal({ diff --git a/src/components/ModalPortal.js b/src/components/ModalPortal.js index 85fd693b..a510a019 100644 --- a/src/components/ModalPortal.js +++ b/src/components/ModalPortal.js @@ -208,7 +208,10 @@ export default class ModalPortal extends Component { this.setState({ afterOpen: true }); if (this.props.isOpen && this.props.onAfterOpen) { - this.props.onAfterOpen(); + this.props.onAfterOpen({ + overlayEl: this.overlay, + contentEl: this.content + }); } }); }