From 4726c4352efcad2ec52b82c7cc1454b20c657e88 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Sat, 10 Jun 2017 03:15:37 +0530 Subject: [PATCH] Scroll to the hash only if there's one after an error. (#2224) --- lib/app.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/app.js b/lib/app.js index f8d33cee..63eaa6c6 100644 --- a/lib/app.js +++ b/lib/app.js @@ -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) {