Skip to content

Commit 9eedb9c

Browse files
committed
fix(course-outline): avoid re-finding section
1 parent d5d4160 commit 9eedb9c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/course-outline/outline-sidebar/AddSidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ export const AddSidebar = () => {
397397

398398
const { currentId, subsectionId, sectionId } = selectedContainerState;
399399
const sectionIndex = sections.findIndex((section) => section.id === sectionId);
400-
const subsectionIndex = sections
401-
.find((section) => section.id === sectionId)
400+
const section = sectionIndex >= 0 ? sections[sectionIndex] : undefined;
401+
const subsectionIndex = section
402402
?.childInfo.children.findIndex((subsection) => subsection.id === subsectionId) ?? -1;
403403

404404
if (currentId === subsectionId && sectionId) {

src/course-outline/outline-sidebar/OutlineAlignSidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export const OutlineAlignSidebar = () => {
1919
const handleBack = () => {
2020
const { currentId, subsectionId, sectionId } = selectedContainerState || {};
2121
const sectionIndex = sections.findIndex((section) => section.id === sectionId);
22-
const subsectionIndex = sections
23-
.find((section) => section.id === sectionId)
22+
const section = sectionIndex >= 0 ? sections[sectionIndex] : undefined;
23+
const subsectionIndex = section
2424
?.childInfo.children.findIndex((subsection) => subsection.id === subsectionId) ?? -1;
2525

2626
if (!currentId) {

0 commit comments

Comments
 (0)