From b7a38deb60395f60515e65404f2c73f7ca379912 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Wed, 12 Nov 2014 15:09:54 -0700 Subject: [PATCH] [fixed] Warning caused by trying to focus null element closes #11 --- lib/components/ModalPortal.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/components/ModalPortal.js b/lib/components/ModalPortal.js index 854e0692..4c15c902 100644 --- a/lib/components/ModalPortal.js +++ b/lib/components/ModalPortal.js @@ -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) { @@ -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 () { @@ -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();