From e5155c633eafa4eacca78e8f82b21de4bd2de1d5 Mon Sep 17 00:00:00 2001 From: jquense Date: Fri, 24 Jul 2015 18:46:04 -0400 Subject: [PATCH] [fixed] ensure last focused item can be focused fixes #917 --- src/Modal.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Modal.js b/src/Modal.js index 46c60f6b57..c98041b5e8 100644 --- a/src/Modal.js +++ b/src/Modal.js @@ -360,15 +360,14 @@ const Modal = React.createClass({ let current = domUtils.activeElement(this); let focusInModal = current && domUtils.contains(modalContent, current); - if (this.props.autoFocus && !focusInModal) { + if (modalContent && this.props.autoFocus && !focusInModal) { this.lastFocus = current; - modalContent.focus(); } }, restoreLastFocus () { - if (this.lastFocus) { + if (this.lastFocus && this.lastFocus.focus) { this.lastFocus.focus(); this.lastFocus = null; } @@ -382,7 +381,7 @@ const Modal = React.createClass({ let active = domUtils.activeElement(this); let modal = React.findDOMNode(this.refs.dialog); - if (modal !== active && !domUtils.contains(modal, active)){ + if (modal && modal !== active && !domUtils.contains(modal, active)){ modal.focus(); } },