Skip to content

Commit

Permalink
fix: merge scroll-to-bottom with drag and drop implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
steff456 authored and navinkarkera committed Dec 13, 2023
1 parent b1ce220 commit f04b636
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/course-outline/CourseOutline.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
React, useState, useCallback, useEffect, useRef
React, useState, useCallback, useEffect, useRef,
} from 'react';
import update from 'immutability-helper';
import { DndProvider } from 'react-dnd';
Expand Down Expand Up @@ -88,9 +88,6 @@ const CourseOutline = ({ courseId }) => {
handleDragNDrop,
} = useCourseOutline({ courseId });

useEffect(() => {
scrollToElement(listRef);
}, [sectionsList]);
document.title = getPageHeadTitle(courseName, intl.formatMessage(messages.headingTitle));
const [sections, setSections] = useState(sectionsList);

Expand Down Expand Up @@ -121,7 +118,12 @@ const CourseOutline = ({ courseId }) => {

useEffect(() => {
if (sectionsList) {
setSections(sectionsList);
setSections((prevSections) => {
if(prevSections.length < sectionsList.length) {
scrollToElement(listRef);
}
return sectionsList
});
}
}, [sectionsList]);

Expand Down

0 comments on commit f04b636

Please sign in to comment.