Skip to content

Commit

Permalink
[fixed] check if the modal content is available when async update... (r…
Browse files Browse the repository at this point in the history
…eactjs#1)

It seems that the using redux, we can get a async update in which can fail
when trying to focus the content of the modal.

This should be a temporary fix since the issue is hard to reproduce,
but safe for other applications.
  • Loading branch information
diasbruno committed Jun 20, 2017
1 parent cb6504c commit 07a2753
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/ModalPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export default class ModalPortal extends Component {
}

// Don't steal focus from inner elements
focusContent = () => (!this.contentHasFocus()) && this.content.focus();
focusContent = () =>
(this.content && !this.contentHasFocus()) && this.content.focus();

closeWithTimeout = () => {
const closesAt = Date.now() + this.props.closeTimeoutMS;
Expand Down

0 comments on commit 07a2753

Please sign in to comment.