Skip to content

fix: Course outline — issue when editing Section/Subsection/Unit name, and executing an action on the page #2275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

qasimgulzar
Copy link

@qasimgulzar qasimgulzar commented Jul 14, 2025

Description

Under this PR I have fixed the duplicate subsection card rendering issue.

Supporting information

Link to other information about the change, such as GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

  1. Edit Title of a Section (change test but don't yet save)
  2. Now Click on New Subsection
  3. Without this fix it duplicates the newly added subsections
  4. This PR is supposed to fix this issue.
Screen.Recording.2025-07-14.at.4.29.01.PM.mov

@openedx-webhooks
Copy link

Thanks for the pull request, @qasimgulzar!

This repository is currently maintained by @bradenmacdonald.

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.


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.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 14, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Jul 14, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Needs Tests Run or CLA Signed in Contributions Jul 15, 2025
@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Jul 15, 2025
Copy link
Contributor

@tecoholic tecoholic left a comment

Choose a reason for hiding this comment

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

@qasimgulzar Hi, While this does fix the issue of showing deupicate sections in the UI, ideally we should fix the source of this issue - the state. The useCourseOutline hook seems to the source of the sectionList for the CourseOutline component. Can you kindly investigate the issue of sectionList adding duplicate entries and create a fix for that?

@qasimgulzar
Copy link
Author

@qasimgulzar Hi, While this does fix the issue of showing deupicate sections in the UI, ideally we should fix the source of this issue - the state. The useCourseOutline hook seems to the source of the sectionList for the CourseOutline component. Can you kindly investigate the issue of sectionList adding duplicate entries and create a fix for that?

Sure, let me investigate that way

@qasimgulzar
Copy link
Author

@tecoholic I have updated addSubsection action in slice to prevent the root cause of it.

@e0d
Copy link

e0d commented Jul 16, 2025

@qasimgulzar I notice there are some commit-lint failures. Please note that we use conventional commits across Open edX projects. You can read about the details here. Can you please amend your commit messages to follow our standard?

@e0d e0d removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Jul 16, 2025
@e0d e0d moved this from Needs Tests Run or CLA Signed to Waiting on Author in Contributions Jul 16, 2025
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.25%. Comparing base (77fe2d1) to head (6d19542).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2275      +/-   ##
==========================================
+ Coverage   94.21%   94.25%   +0.03%     
==========================================
  Files        1165     1166       +1     
  Lines       24651    24679      +28     
  Branches     5378     5385       +7     
==========================================
+ Hits        23226    23260      +34     
+ Misses       1347     1343       -4     
+ Partials       78       76       -2     

☔ View full report in Codecov by Sentry.
📢 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.

@qasimgulzar
Copy link
Author

@e0d I just updated the message

Copy link
Contributor

@tecoholic tecoholic left a comment

Choose a reason for hiding this comment

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

@qasimgulzar 👍 LGTM

  • I tested this: I verified that the duplicate subsection's aren't added.
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

Reviewer notes

I was curious as to how the section came to have the subsection information (requiring this filtering) in the first place. So did a bit of digging:

  • When the user clicks the New subsection button without saving the changes in the section title, 2 POST requests are made.
    1. To autosave the title update using the editCourseItemQuery
    2. To create a new subsection
  • editCourseItemQuery makes a GET request as soon as the POST is complete to update the section data.
  • This ends up updating the state with the result of both the POST requets.
  • So, when the addSubsection is finally called, the state already has subsection data leading to duplication during the array update.

This PR fixes it by filtering out the subsection data and re-adding it.

Copy link
Contributor

@xitij2000 xitij2000 left a comment

Choose a reason for hiding this comment

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

Unfortunately this is just not working for me. When I edit a section title and then click on new subsection, nothing happens, no new subsection is created at all.

I think a solution to this kind of desynced state could also be to simply disable the new unit, subsection and section buttons while a title is being edited. Currently this doesn't seem to solve the issue for me.

@xitij2000
Copy link
Contributor

@qasimgulzar Sorry it seems the issue was on my side, I'm approving this again, please resolve the conflicts and then I can merge.

@@ -140,7 +140,7 @@ const slice = createSlice({
state.sectionsList = state.sectionsList.map((section) => {
if (section.id === payload.parentLocator) {
section.childInfo.children = [
...section.childInfo.children,
...section.childInfo.children.filter(child => child.id !== payload.data.id),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment here about why this filtering is happening since it isn't obvious.

Copy link
Author

Choose a reason for hiding this comment

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

@xitij2000 I just updated the PR

@qasimgulzar
Copy link
Author

@xitij2000 I have resolve the conflicts please merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Status: Waiting on Author
Development

Successfully merging this pull request may close these issues.

6 participants