Scroll to top when the sequenceId or unitId changes (#63)

* Scroll to top when the sequenceId or unitId changes

* Add a spinner to the unit.
This commit is contained in:
David Joy
2020-05-06 12:59:17 -04:00
committed by GitHub
parent a718c67f36
commit 29b234e2f0
2 changed files with 11 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
import React, { Suspense } from 'react';
import React, { Suspense, useEffect } from 'react';
import PropTypes from 'prop-types';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import PageLoading from '../../../PageLoading';
@@ -14,6 +14,11 @@ function SequenceContent({
}) {
const sequence = useModel('sequences', sequenceId);
// Go back to the top of the page whenever the unit or sequence changes.
useEffect(() => {
global.scrollTo(0, 0);
}, [sequenceId, unitId]);
if (gated) {
return (
<Suspense

View File

@@ -117,6 +117,11 @@ function Unit({
/>
</Suspense>
)}
{!hasLoaded && (
<PageLoading
srMessage={intl.formatMessage(messages['learn.loading.learning.sequence'])}
/>
)}
<div className="unit-iframe-wrapper">
<iframe
id="unit-iframe"