From 42d601e214fff7c6909f5a3c8a923550c622e4f0 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 14 Jul 2020 12:19:52 -0700 Subject: [PATCH] help: Fix exception with invalid fragment causing bogus extra scrollbars. Apparently, our scrollbar logic crashed with an invalid URL fragment (hash), which resulted in initialization not completing and thus the logic failing. In my view the root issue here is that we're not doing a good job of catching JavaScript exceptions in portico pages. Fixes #15706. --- static/js/portico/help.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/portico/help.js b/static/js/portico/help.js index 16024858ac..c324dd042c 100644 --- a/static/js/portico/help.js +++ b/static/js/portico/help.js @@ -56,7 +56,7 @@ function render_code_sections() { function scrollToHash(simplebar) { const hash = window.location.hash; const scrollbar = simplebar.getScrollElement(); - if (hash !== '') { + if (hash !== '' && $(hash).length > 0) { const position = $(hash).position().top - $(scrollbar.firstChild).position().top; scrollbar.scrollTop = position; } else {