From 2314043432837411b5319872d584a707d3c0ce48 Mon Sep 17 00:00:00 2001 From: ktmouk Date: Fri, 20 Oct 2023 04:32:52 +0900 Subject: [PATCH] Fix anchors not working (#20255) --- app/javascript/packs/base.jsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/javascript/packs/base.jsx b/app/javascript/packs/base.jsx index da1a73619..857d9251b 100644 --- a/app/javascript/packs/base.jsx +++ b/app/javascript/packs/base.jsx @@ -170,6 +170,15 @@ if (document.location.pathname === '/admin/creator_settings/new') { } document.ready.then(() => { + // Our infinite scroll pattern causes problems with the browser's back button: + // specifically, if you've scrolled into page 2+, click into a post, then back + // to the feed, the browser scroll position will not be where you had previously + // scrolled. This seems to fix it, even though it seems like it should have + // the opposite effect. + setTimeout(() => { + history.scrollRestoration = 'manual'; + }, 0); + const hamburgerTrigger = document.getElementsByClassName( 'js-hamburger-trigger', )[0]; @@ -179,10 +188,3 @@ document.ready.then(() => { trackCreateAccountClicks('authentication-hamburger-actions'); trackCreateAccountClicks('authentication-top-nav-actions'); trackCreateAccountClicks('comments-locked-cta'); - -// Our infinite scroll pattern causes problems with the browser's back button: -// specifically, if you've scrolled into page 2+, click into a post, then back -// to the feed, the browser scroll position will not be where you had previously -// scrolled. This seems to fix it, even though it seems like it should have -// the opposite effect. -history.scrollRestoration = 'manual';