From 187598442338a59c3990f30b5a36a17abe3c80b0 Mon Sep 17 00:00:00 2001 From: Tom <20648924+moT01@users.noreply.github.com> Date: Fri, 29 Jan 2021 07:21:52 -0600 Subject: [PATCH] fix(client): remove auto scroll on superBlock page (#40828) --- .../templates/Introduction/SuperBlockIntro.js | 44 ++----------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/client/src/templates/Introduction/SuperBlockIntro.js b/client/src/templates/Introduction/SuperBlockIntro.js index 401999fc8d..ce8e31cba8 100644 --- a/client/src/templates/Introduction/SuperBlockIntro.js +++ b/client/src/templates/Introduction/SuperBlockIntro.js @@ -69,31 +69,11 @@ const mapDispatchToProps = dispatch => ); export class SuperBlockIntroductionPage extends Component { - constructor(props) { - super(props); - this.elementRef = React.createRef(); - } - componentDidMount() { this.initializeExpandedState(); - this.scrollToBlock(); } - componentDidUpdate() { - this.scrollToBlock(); - } - - scrollToBlock() { - if (this.elementRef.current) { - setTimeout(() => { - const scrollTo = this.elementRef.current.offsetTop; - - window.scrollTo({ top: scrollTo, left: 0, behavior: 'smooth' }); - }, 300); - } - } - - getChosenBlock(forScrolling) { + getChosenBlock() { const { data: { allChallengeNode: { edges } @@ -120,7 +100,7 @@ export class SuperBlockIntroductionPage extends Component { : edge.node.block; } - return forScrolling ? 'top' : edge.node.block; + return edge.node.block; } initializeExpandedState() { @@ -138,7 +118,6 @@ export class SuperBlockIntroductionPage extends Component { }, allChallengeNode: { edges } }, - fetchState: { pending, complete }, isSignedIn, t } = this.props; @@ -150,21 +129,13 @@ export class SuperBlockIntroductionPage extends Component { const i18nSuperBlock = t(`intro:${superBlockDashedName}.title`); - let blockToScrollTo; - if (!pending && complete) { - blockToScrollTo = this.getChosenBlock(true); - } - return ( <> {i18nSuperBlock} | freeCodeCamp.org - + @@ -175,14 +146,7 @@ export class SuperBlockIntroductionPage extends Component {
{blockDashedNames.map(blockDashedName => ( -
+