Skip to content

Commit

Permalink
[fixed] Warning caused by trying to focus null element
Browse files Browse the repository at this point in the history
closes #11
  • Loading branch information
mzabriskie committed Nov 12, 2014
1 parent 2ac5290 commit b7a38de
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/components/ModalPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ var ModalPortal = module.exports = React.createClass({
// Focus needs to be set when mounting and already open
if (this.props.isOpen) {
this.setFocusAfterRender(true);
this.open();
}
this.handleProps(this.props);
},

componentWillReceiveProps: function(newProps) {
Expand All @@ -46,7 +46,10 @@ var ModalPortal = module.exports = React.createClass({
this.setFocusAfterRender(true);
}

this.handleProps(newProps);
if (newProps.isOpen === true)
this.open();
else if (newProps.isOpen === false)
this.close();
},

componentDidUpdate: function () {
Expand All @@ -60,13 +63,6 @@ var ModalPortal = module.exports = React.createClass({
this.focusAfterRender = focus;
},

handleProps: function(props) {
if (props.isOpen === true)
this.open();
else if (props.isOpen === false)
this.close();
},

open: function() {
focusManager.setupScopedFocus(this.getDOMNode());
focusManager.markForFocusLater();
Expand Down

0 comments on commit b7a38de

Please sign in to comment.