Skip to content

Commit

Permalink
[added]: pass overlay and content element references to onAfterOpen fn (
Browse files Browse the repository at this point in the history
  • Loading branch information
baruchvlz authored and diasbruno committed Oct 8, 2019
1 parent 9be00a9 commit 4ac3ff4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions specs/Modal.events.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
5 changes: 4 additions & 1 deletion src/components/ModalPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
});
}
Expand Down

0 comments on commit 4ac3ff4

Please sign in to comment.