Skip to content

Commit

Permalink
[fixed] Modal error when backdrop is false
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Jul 28, 2015
1 parent 7720d2c commit d89d5f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ const Modal = React.createClass({
},

_setDialogRef(ref){
// issue #1074
// due to: https://github.com/facebook/react/blob/v0.13.3/src/core/ReactCompositeComponent.js#L842
//
// when backdrop is `false` react hasn't had a chance to reassign the refs to a usable object, b/c there are no other
// "classic" refs on the component (or they haven't been processed yet)
// TODO: Remove the need for this in next breaking release
if (Object.isFrozen(this.refs) && !Object.keys(this.refs).length) {
this.refs = {};
}

this.refs.dialog = ref;

//maintains backwards compat with older component breakdown
Expand Down
11 changes: 11 additions & 0 deletions test/ModalSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ describe('Modal', function () {
assert.match(dialog.props.className, /\btestCss\b/);
});

it('Should assign refs correctly when no backdrop', function () {

let test = () => render(
<Modal show backdrop={false} onHide={function () {}}>
<strong>Message</strong>
</Modal>
, mountPoint);

expect(test).not.to.throw();
});

it('Should pass transition callbacks to Transition', function (done) {
let count = 0;
let increment = ()=> count++;
Expand Down

0 comments on commit d89d5f3

Please sign in to comment.