From ae6fe935b697e6d53b1700efbe62d7f6e4243039 Mon Sep 17 00:00:00 2001 From: Hieu Lam Date: Tue, 25 Jun 2019 09:42:09 +0700 Subject: [PATCH] =?UTF-8?q?fix(Modal):=20update=20condition=20to=20call=20?= =?UTF-8?q?`setFocus`=20in=20case=20open=20mo=E2=80=A6=20(#1514)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Modal.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Modal.js b/src/Modal.js index e663a9dc9..525a042c0 100644 --- a/src/Modal.js +++ b/src/Modal.js @@ -105,17 +105,18 @@ class Modal extends React.Component { } componentDidMount() { - if (this.props.isOpen) { + const { isOpen, autoFocus, onEnter } = this.props; + + if (isOpen) { this.init(); this.setState({ isOpen: true }) + if (autoFocus) { + this.setFocus(); + } } - if (this.props.onEnter) { - this.props.onEnter(); - } - - if (this.state.isOpen && this.props.autoFocus) { - this.setFocus(); + if (onEnter) { + onEnter(); } this._isMounted = true;