-
Notifications
You must be signed in to change notification settings - Fork 142
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, @qasimgulzar! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
There was a problem hiding this 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?
Sure, let me investigate that way |
@tecoholic I have updated |
@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? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
@e0d I just updated the message |
There was a problem hiding this 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.
- To autosave the title update using the editCourseItemQuery
- 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.
There was a problem hiding this 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.
@qasimgulzar Sorry it seems the issue was on my side, I'm approving this again, please resolve the conflicts and then I can merge. |
src/course-outline/data/slice.js
Outdated
@@ -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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@xitij2000 I have resolve the conflicts please merge. |
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
New Subsection
Screen.Recording.2025-07-14.at.4.29.01.PM.mov