Skip to content

Commit

Permalink
Scroll to the hash only if there's one after an error. (vercel#2224)
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoda authored and timneutkens committed Jun 9, 2017
1 parent ad4ec55 commit 4726c43
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 44,14 @@ class Container extends Component {

scrollToHash () {
const { hash } = this.props
if (!hash) return

const el = document.getElementById(hash)
if (el) {
// If we call scrollIntoView() in here without a setTimeout
// it won't scroll properly.
setTimeout(() => el.scrollIntoView(), 0)
}
if (!el) return

// If we call scrollIntoView() in here without a setTimeout
// it won't scroll properly.
setTimeout(() => el.scrollIntoView(), 0)
}

shouldComponentUpdate (nextProps) {
Expand Down

0 comments on commit 4726c43

Please sign in to comment.