Skip to content

Commit

Permalink
Don’t steal focus from [autofocus] elements.
Browse files Browse the repository at this point in the history
Fixes reach#158
  • Loading branch information
ryanflorence committed Sep 21, 2018
1 parent 8a56262 commit a7a1c84
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ class FocusHandlerImpl extends React.Component {
if (initialRender) {
initialRender = false;
} else {
this.node.focus();
// React polyfills [autofocus] and it fires earlier than cDM,
// so we were stealing focus away, this line prevents that.
if (!this.node.contains(document.activeElement)) {
this.node.focus();
}
}
}
}
Expand Down

0 comments on commit a7a1c84

Please sign in to comment.