diff --git a/.env b/.env index b162247399..593c30b8c6 100644 --- a/.env +++ b/.env @@ -13,6 +13,7 @@ DISCOVERY_API_BASE_URL='' DISCUSSIONS_MFE_BASE_URL='' ECOMMERCE_BASE_URL='' ENABLE_JUMPNAV='true' +ENABLE_LEGACY_NAV='' ENABLE_NOTICES='' ENTERPRISE_LEARNER_PORTAL_HOSTNAME='' EXAMS_BASE_URL='' diff --git a/.env.development b/.env.development index 34e014efb0..ec6c3a6ced 100644 --- a/.env.development +++ b/.env.development @@ -13,6 +13,7 @@ DISCOVERY_API_BASE_URL='http://localhost:18381' DISCUSSIONS_MFE_BASE_URL='http://localhost:2002' ECOMMERCE_BASE_URL='http://localhost:18130' ENABLE_JUMPNAV='true' +ENABLE_LEGACY_NAV='' ENABLE_NOTICES='' ENTERPRISE_LEARNER_PORTAL_HOSTNAME='localhost:8734' EXAMS_BASE_URL='' diff --git a/README.rst b/README.rst index b1d2f39678..23a55e5408 100644 --- a/README.rst +++ b/README.rst @@ -80,6 +80,10 @@ ENABLE_JUMPNAV This feature flag is slated to be removed as jumpnav becomes default. Follow the progress of this ticket here: https://openedx.atlassian.net/browse/TNL-8678 +ENABLE_LEGACY_NAV + Enables the legacy behaviour in the course breadcrumbs, where links lead to + the course index highlighting the selected course section or subsection. + SOCIAL_UTM_MILESTONE_CAMPAIGN This value is passed as the ``utm_campaign`` parameter for social-share links when celebrating learning milestones in the course. Optional. diff --git a/src/course-home/outline-tab/LmsHtmlFragment.jsx b/src/course-home/outline-tab/LmsHtmlFragment.jsx index 191663554c..3c061d0fad 100644 --- a/src/course-home/outline-tab/LmsHtmlFragment.jsx +++ b/src/course-home/outline-tab/LmsHtmlFragment.jsx @@ -29,7 +29,7 @@ const LmsHtmlFragment = ({ const iframe = useRef(null); function resetIframeHeight() { if (iframe?.current?.contentWindow?.document?.body) { - iframe.current.height = iframe.current.contentWindow.document.body.scrollHeight; + iframe.current.height = iframe.current.contentWindow.document.body.parentNode.scrollHeight; } } diff --git a/src/course-home/outline-tab/OutlineTab.jsx b/src/course-home/outline-tab/OutlineTab.jsx index a2ce8101ea..c7c46a39fc 100644 --- a/src/course-home/outline-tab/OutlineTab.jsx +++ b/src/course-home/outline-tab/OutlineTab.jsx @@ -123,6 +123,15 @@ const OutlineTab = ({ intl }) => { } }, [location.search]); + // A section or subsection is selected by its id being the location hash part. + // location.hash will contain an initial # sign, so remove it here. + const hashValue = location.hash.substring(1); + // Represents whether section is either selected or contains selected + // subsection and thus should be expanded by default. + const selectedSectionId = rootCourseId && courses[rootCourseId].sectionIds.find((sectionId) => ( + (hashValue === sectionId) || sections[sectionId].sequenceIds.includes(hashValue) + )); + return ( <>
' + + '' + + '' + + 'Test welcome message that happens to be longer than one hundred words because of comments but displayed content is less.' + + 'It should not be shortened.' + + '' + + '' + + '
', + }); + await fetchAndRender(); + const showMoreButton = screen.queryByRole('button', { name: 'Show More' }); + expect(showMoreButton).not.toBeInTheDocument(); + }); + it('does not display if no update available', async () => { setTabData({ welcome_message_html: null }); await fetchAndRender(); diff --git a/src/course-home/outline-tab/Section.jsx b/src/course-home/outline-tab/Section.jsx index 3de888a89a..60d83269fd 100644 --- a/src/course-home/outline-tab/Section.jsx +++ b/src/course-home/outline-tab/Section.jsx @@ -1,5 +1,7 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; +import classNames from 'classnames'; +import { useLocation } from 'react-router-dom'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { Collapsible, IconButton } from '@edx/paragon'; import { faCheckCircle as fasCheckCircle, faMinus, faPlus } from '@fortawesome/free-solid-svg-icons'; @@ -10,7 +12,9 @@ import SequenceLink from './SequenceLink'; import { useModel } from '../../generic/model-store'; import genericMessages from '../../generic/messages'; +import { useScrollTo } from './hooks'; import messages from './messages'; +import './Section.scss'; const Section = ({ courseId, @@ -29,6 +33,10 @@ const Section = ({ sequences, }, } = useModel('outline', courseId); + // A section or subsection is selected by its id being the location hash part. + // location.hash will contain an initial # sign, so remove it here. + const hashValue = useLocation().hash.substring(1); + const selected = hashValue === section.id; const [open, setOpen] = useState(defaultOpen); @@ -41,6 +49,8 @@ const Section = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + const sectionRef = useScrollTo(selected); + const sectionTitle = (