diff --git a/services/web/app/views/layout/fat-footer.pug b/services/web/app/views/layout/fat-footer.pug index 99dcdf49e6..0e377affcd 100644 --- a/services/web/app/views/layout/fat-footer.pug +++ b/services/web/app/views/layout/fat-footer.pug @@ -54,7 +54,7 @@ footer.fat-footer.hidden-print li a(href="/for/universities") #{translate('for_universities')} li - a(href="/user/subscription/plans#view=student?itm_referrer=footer-for-students") #{translate('for_students')} + a(href="/user/subscription/plans?itm_referrer=footer-for-students#view=student") #{translate('for_students')} .footer-section .footer-section-heading #{translate('get_involved')} diff --git a/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js b/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js index 0e7940ee00..e2acdba975 100644 --- a/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js +++ b/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js @@ -170,8 +170,25 @@ function selectViewFromHash() { // set annual as the default currentMonthlyAnnualSwitchValue = 'annual' selectTab(view) + // clear the hash so it doesn't persist when switching plans - window.location.hash = '' + const currentURL = window.location.pathname + window.location.search + history.replaceState('', document.title, currentURL) + + // Add a small delay since it seems the scroll won't behave correctly on this scenario: + // 1. Open plans page + // 2. Click on "Group Plans" + // 3. Scroll down to footer + // 4. Click "For students" link + // + // I assume this is happening because the `selectTab` function above is doing a lot + // of computation to change the view and it somehow prevents the `window.scrollTo` command + // to behave correctly. + const SCROLL_TO_TOP_DELAY = 50 + + window.setTimeout(() => { + window.scrollTo({ top: 0, behavior: 'smooth' }) + }, SCROLL_TO_TOP_DELAY) } } } catch {