Skip to content

Commit

Permalink
[fixed] Modal does not fire show callback
Browse files Browse the repository at this point in the history
  • Loading branch information
nickuraltsev committed Nov 19, 2015
1 parent 44dda40 commit 742c3c1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ const Modal = React.createClass({
addFocusListener(this.enforceFocus);

this.focus();

if (this.props.onShow) {
this.props.onShow();
}
},

onHide() {
Expand Down
24 changes: 24 additions & 0 deletions test/ModalSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,30 @@ describe('Modal', function () {
, mountPoint);
});

it('Should fire show callback on mount', function () {
let onShowSpy = sinon.spy();
render(
<Modal show onShow={onShowSpy}>
<strong>Message</strong>
</Modal>
, mountPoint);

expect(onShowSpy).to.have.been.calledOnce;
});

it('Should fire show callback on update', function () {
let onShowSpy = sinon.spy();
let instance = render(
<Modal onShow={onShowSpy}>
<strong>Message</strong>
</Modal>
, mountPoint);

instance.renderWithProps({ show: true });

expect(onShowSpy).to.have.been.calledOnce;
});

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

Expand Down

0 comments on commit 742c3c1

Please sign in to comment.