Skip to content

feat: Course outline restructure with new plugin slots - #1920

Open
xitij2000 wants to merge 2 commits into
openedx:masterfrom
open-craft:kshitij/course-outline-refactor-and-slots
Open

feat: Course outline restructure with new plugin slots#1920
xitij2000 wants to merge 2 commits into
openedx:masterfrom
open-craft:kshitij/course-outline-refactor-and-slots

Conversation

@xitij2000

Copy link
Copy Markdown
Contributor

Splits useCourseOutlineSidebar into useCourseOutlineData + useCourseOutlineSidebar, adds CourseOutlineSidebarHeadingSlot, CourseOutlineSidebarSectionCompletionIconSlot, and CourseOutlineSidebarSequenceCompletionIconSlot, and introduces CSS variables for theming the sidebar.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels May 27, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @xitij2000!

This repository is currently maintained by @openedx/committers-frontend-app-learning.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions May 27, 2026
@xitij2000
xitij2000 force-pushed the kshitij/course-outline-refactor-and-slots branch from 44ec042 to cd853d0 Compare May 27, 2026 10:22
@xitij2000 xitij2000 changed the title refactor: Course outline restructure with new plugin slots and CSS variables refactor: Course outline restructure with new plugin slots May 27, 2026
@xitij2000 xitij2000 changed the title refactor: Course outline restructure with new plugin slots feat: Course outline restructure with new plugin slots May 27, 2026
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.88%. Comparing base (1724600) to head (7053d03).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1920      +/-   ##
==========================================
+ Coverage   92.86%   92.88%   +0.01%     
==========================================
  Files         360      360              
  Lines        5890     5901      +11     
  Branches     1407     1410       +3     
==========================================
+ Hits         5470     5481      +11     
  Misses        402      402              
  Partials       18       18              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@itsjeyd itsjeyd moved this from Needs Triage to Ready for Review in Contributions Jun 3, 2026
@itsjeyd itsjeyd added the waiting for eng review PR is ready for review. Review and merge it, or suggest changes. label Jun 3, 2026
@itsjeyd
itsjeyd requested review from a team and brian-smith-tcril June 9, 2026 13:49
@xitij2000

Copy link
Copy Markdown
Contributor Author

@brian-smith-tcril Did you get a chance to look at this PR?

@brian-smith-tcril

Copy link
Copy Markdown
Contributor

@brian-smith-tcril Did you get a chance to look at this PR?

Not quite yet. I've been focused on a release testing bug fix. I definitely haven't forgotten about it and it's still high on my todo list.

@brian-smith-tcril brian-smith-tcril left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall these extension points seem like good ones to add. Looking forward to continuing to discuss these changes and finding a good path for them to land!


return (
<li className={classNames({ 'bg-info-100': isActive, 'border-top border-light': !isFirst })}>
<li className={classNames({ 'active-unit bg-info-100': isActive, 'border-top border-light': !isFirst })}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

active-unit doesn't appear to exist.

@xitij2000

Copy link
Copy Markdown
Contributor Author

@brian-smith-tcril

Just giving context on some of the issues:

  • I removed some of the padding, and colors classes so that themes can more easily override those. Unfortunately I had move them to the CSS file but those changes are lost. I can reimplement it, or revert to the original classes if what I'm planning is unacceptable.
  • I've added active-unit and active-section to allow themes to override these styles even if the default theme doesn't do it or does it by simply applying a class.

I tried splitting this PR into two parts, however there were quite a few dependencies between the commits so it wasn't as easy a split as I hoped. I'll apply the other fixes first.

@xitij2000
xitij2000 force-pushed the kshitij/course-outline-refactor-and-slots branch from dc917eb to d627014 Compare June 17, 2026 13:53
@brian-smith-tcril

Copy link
Copy Markdown
Contributor

I removed some of the padding, and colors classes so that themes can more easily override those. Unfortunately I had move them to the CSS file but those changes are lost. I can reimplement it, or revert to the original classes if what I'm planning is unacceptable.

I'm open to discussing those changes, but I'd like to keep this PR focused on adding the plugin slots. By keeping the PR focused we won't have changes blocking each other from landing.

I've added active-unit and active-section to allow themes to override these styles even if the default theme doesn't do it or does it by simply applying a class.

That's probably fine, but I'd still prefer to have this as a "just adding slots" PR.

I tried splitting this PR into two parts, however there were quite a few dependencies between the commits so it wasn't as easy a split as I hoped. I'll apply the other fixes first.

I'm sorry about that. I know it can be frustrating to split things up, but I think the benefits of focused PRs are very real.

@xitij2000

Copy link
Copy Markdown
Contributor Author

@brian-smith-tcril I've split out the slots into this PR: #1933

A test is failing locally so I still have work to do, but I'll rebase this PR once that one is merged.

@itsjeyd itsjeyd moved this from Ready for Review to In Eng Review in Contributions Jun 24, 2026
@itsjeyd itsjeyd added blocked by other work PR cannot be finished until other work is complete and removed waiting for eng review PR is ready for review. Review and merge it, or suggest changes. labels Jun 24, 2026
@xitij2000
xitij2000 force-pushed the kshitij/course-outline-refactor-and-slots branch 2 times, most recently from c3daaa0 to f59ca84 Compare July 22, 2026 14:51
variant="tertiary"
className={classNames(
'd-flex align-items-center w-100 px-4 py-3.5 rounded-0 justify-content-start',
{ 'bg-info-100': isActiveSection },

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now applied via SCSS

@xitij2000
xitij2000 force-pushed the kshitij/course-outline-refactor-and-slots branch 2 times, most recently from cc980c5 to 614ced5 Compare July 23, 2026 09:06
@xitij2000

Copy link
Copy Markdown
Contributor Author

@brian-smith-tcril I've updated this PR.

FYI: the update to the ARCHITECTURE.md file was made using claude.

@itsjeyd itsjeyd added waiting for eng review PR is ready for review. Review and merge it, or suggest changes. and removed blocked by other work PR cannot be finished until other work is complete labels Jul 28, 2026
@itsjeyd

itsjeyd commented Aug 12, 2026

Copy link
Copy Markdown

Hi @brian-smith-tcril, would you have time to take another look at this PR?

@brian-smith-tcril

Copy link
Copy Markdown
Contributor

@itsjeyd I took another look and resolved a lot of my old comments.

@xitij2000 this PR has a conflict in SidebarUnit.jsx, knowing how that gets resolved would make the next review pass much smoother, so if you could rebase this that would be perfect!

Splits useCourseOutlineSidebar into useCourseOutlineData and
useCourseOutlineSidebar for improved separation of responsibilities.
Updates components to reflect this change.

This allows the course outline to be used outside of a sidebar context.
@xitij2000
xitij2000 force-pushed the kshitij/course-outline-refactor-and-slots branch from 614ced5 to 7053d03 Compare August 18, 2026 11:50
@xitij2000

Copy link
Copy Markdown
Contributor Author

@brian-smith-tcril That conflict had to do with the styling changes which I've removed. This is ready now. I'll prepare another PR for the styling changes.

@brian-smith-tcril brian-smith-tcril left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finally feel like I was able to wrap my head around these changes. Overall it's looking pretty good. I left a few comments in there with suggestions/questions, looking forward to hearing your thoughts!

Comment on lines +22 to +25
interface CoursePageParams extends Record<string, string> {
courseId: string;
unitId: string;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude called this out

The non-optional declarations do nothing. courseId: string; unitId: string come back through Partial<> as string | undefined regardless. That's precisely why the author still had to write courseId! and unitId! at lines 100 and 103 — the interface claims the params are always present, the type system disagrees, and the ! papers over the gap. The interface is stating a guarantee it can't deliver, and the route /course/:courseId/:sequenceId (constants.ts:16) means unitId genuinely is absent sometimes.

Comment thread src/courseware/course/sidebar/sidebars/course-outline/hooks.js
Comment thread src/courseware/course/sidebar/sidebars/course-outline/hooks.js
Comment thread src/courseware/course/sidebar/sidebars/course-outline/hooks.js
Comment on lines +35 to +41
const handleClick = React.useCallback(() => {
// Hide the sidebar after selecting a unit on a mobile device.
if (shouldDisplayFullScreen) {
handleToggleCollapse();
}
handleUnitClick({ sequenceId, activeUnitId, id });
}, [handleUnitClick, sequenceId, activeUnitId, id, shouldDisplayFullScreen, handleToggleCollapse]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this block a few things stand out to me:

  • It's no longer inline
    • This makes sense, we used to have the handleToggleCollapse in handleUnitClick, now that needs to be called here instead, making it a named function seems reasonable.
  • The if (shouldDisplayFullScreen) { handleToggleCollapse block is before handleUnitClick
    • That block was at the end of handleUnitClick before. I don't think there's a behavioral difference with it moving, but it stood out to me as a difference to investigate.
  • It is now using useCallback instead of a plain arrow function.
    • It's not clear to me what this is buying us. I'm open to the change if there's clear justification, but I'd think sticking to a plain arrow function here would be fine.

Claude dive into why useCallback isn't buying us anything

  1. Something re-renders UnitLinkWrapper.
  2. UnitLinkWrapper() runs again, so useCourseOutlineData() runs again.
  3. That hook's line const handleUnitClick = (...) => {...} executes again → allocates a different function object than last render.
  4. useCallback compares this render's deps to last render's with Object.is. handleUnitClick is a different object, so that check fails.
  5. Cache miss → useCallback returns a newly created handleClick.

Comment thread src/courseware/course/sidebar/sidebars/course-outline/hooks.js
const [selectedSection, setSelectedSection] = useState<string | null>(null);
const [isDisplaySequenceLevel, setDisplaySequenceLevel, setDisplaySectionLevel] = useToggle(true);

const { unitId, courseId } = useParams<CoursePageParams>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any test changes in this PR. Were there tests assuming we were getting a unitId from useCourseOutlineSidebar before that need to be updated to have one provided by params?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is a good point. I think the fact that not tests fail after moving the source from Sidebar context to useParams means that the tests were probably not testing how unitId is used.

return null;
}
return <CourseOutline />;
return <CourseOutline shouldDisplayFullScreen={shouldDisplayFullScreen} onToggleCollapse={handleToggleCollapse} />;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude question about this:

Why props here instead of having CourseOutline call useCourseOutlineSidebar() directly? Every other consumer in this subtree — the trigger, UnitLinkWrapper — reads the sidebar hook itself, so CourseOutline becomes the only component being fed these two values from outside. If the intent is to make CourseOutline renderable outside a sidebar, could the props fall back to the context values when they aren't passed, rather than to false/undefined? That way the sidebar case keeps working through the hook as it does today (and CourseOutlineTray doesn't need to pass anything at all), and the props become an explicit override for the out-of-sidebar case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having CourseOuline call useCourseOutlineSidebar is the exact reason for this refactoring in the first place, we want to make it independent of any sidebar logic. Having it still get it from the SidebarContext would partially defeat the purpose of the split.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having CourseOuline call useCourseOutlineSidebar is the exact reason for this refactoring in the first place, we want to make it independent of any sidebar logic. Having it still get it from the SidebarContext would partially defeat the purpose of the split.

Could you elaborate on this a bit? My feeling is that regardless of where CourseOutline gets shouldDisplayFullScreen and handleToggleCollapse from, by caring about those at all it's including "sidebar logic."

I'm open to these being passed as props, I just want to understand the motivation a bit better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, that is how those values are currently used. However for a client we extracted this component and injected it in the header as a dropdown. It can still use the toggle collapse, but its context is different from that of a sidebar. This work was triggered by the need for hosting this component outside the sidebar. Having the values passed explicitly seemed to be a cleaner separation.

That said it's still in the sidebars folder so without further refactoring it's still somewhat tied to the sidebar and keeping the values by default won't break anything.

We could do further refactoring to move this out and make the fullscreen code part of the sidebar wrapper rather than the outline component, but I think for now I can make these params default to the sidebar context values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't read through this file fully but it looks like it might need to be updated, so this is just a note to make sure this file accurately reflects the current state of the repo with the changes in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U waiting for eng review PR is ready for review. Review and merge it, or suggest changes.

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

4 participants