Skip to content

Commit

Permalink
fix(Modal): update condition to call setFocus in case open mo… (#1514)
Browse files Browse the repository at this point in the history
  • Loading branch information
lh0x00 authored and TheSharpieOne committed Jun 25, 2019
1 parent 01f474f commit ae6fe93
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Modal.js
Expand Up @@ -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;
Expand Down

0 comments on commit ae6fe93

Please sign in to comment.