Skip to content

Commit 4ac3ff4

Browse files
baruchvlzdiasbruno
authored andcommitted
[added]: pass overlay and content element references to onAfterOpen fn (#741)
1 parent 9be00a9 commit 4ac3ff4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

specs/Modal.events.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ export default () => {
2525
afterOpenCallback.called.should.be.ok();
2626
});
2727

28+
it("should call onAfterOpen with overlay and content references", () => {
29+
const afterOpenCallback = sinon.spy();
30+
const modal = renderModal({ isOpen: true, onAfterOpen: afterOpenCallback });
31+
32+
sinon.assert.calledWith(afterOpenCallback, {
33+
overlayEl: modal.portal.overlay,
34+
contentEl: modal.portal.content
35+
});
36+
});
37+
2838
it("should trigger the onAfterClose callback", () => {
2939
const onAfterCloseCallback = sinon.spy();
3040
const modal = renderModal({

src/components/ModalPortal.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ export default class ModalPortal extends Component {
208208
this.setState({ afterOpen: true });
209209

210210
if (this.props.isOpen && this.props.onAfterOpen) {
211-
this.props.onAfterOpen();
211+
this.props.onAfterOpen({
212+
overlayEl: this.overlay,
213+
contentEl: this.content
214+
});
212215
}
213216
});
214217
}

0 commit comments

Comments
 (0)