From 18323bda5a6bc0e3a2f22457323e1c9a7189e43b Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Wed, 29 Nov 2023 13:44:15 -0500 Subject: [PATCH 1/4] feat: add auto scroll to new sections when created --- src/course-outline/CourseOutline.jsx | 9 ++++++++- src/course-outline/section-card/SectionCard.jsx | 15 ++++++++++----- src/course-outline/utils.jsx | 8 ++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/course-outline/CourseOutline.jsx b/src/course-outline/CourseOutline.jsx index dd9c5f65d6..9d748b7aab 100644 --- a/src/course-outline/CourseOutline.jsx +++ b/src/course-outline/CourseOutline.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import { React, useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import { useIntl } from '@edx/frontend-platform/i18n'; import { @@ -34,8 +34,10 @@ import ConfigureModal from './configure-modal/ConfigureModal'; import DeleteModal from './delete-modal/DeleteModal'; import { useCourseOutline } from './hooks'; import messages from './messages'; +import { scrollToBottom } from './utils'; const CourseOutline = ({ courseId }) => { + const listRef = useRef(null); const intl = useIntl(); const { @@ -77,6 +79,10 @@ const CourseOutline = ({ courseId }) => { handleNewSectionSubmit, } = useCourseOutline({ courseId }); + useEffect(() => { + scrollToBottom(listRef); + }, [sectionsList]); + const { isShow: isShowProcessingNotification, title: processingNotificationTitle, @@ -155,6 +161,7 @@ const CourseOutline = ({ courseId }) => { onEditSectionSubmit={handleEditSectionSubmit} onDuplicateSubmit={handleDuplicateSectionSubmit} isSectionsExpanded={isSectionsExpanded} + ref={listRef} /> ))}