Skip to content

fix: prevent full iframe reload after xblock edition#2257

Closed
bra-i-am wants to merge 9 commits intoopenedx:masterfrom
eduNEXT:bc/authoring#1893
Closed

fix: prevent full iframe reload after xblock edition#2257
bra-i-am wants to merge 9 commits intoopenedx:masterfrom
eduNEXT:bc/authoring#1893

Conversation

@bra-i-am
Copy link
Copy Markdown
Contributor

@bra-i-am bra-i-am commented Jul 4, 2025

Description

This PR addresses an issue that causes a full iframe reload after saving edited xblock data. To prevent the page reload, these changes remove the entire iframe reload, which was part of a previous implementation to display the Publish button after editing an xblock. However, this PR uses a different approach to achieve that.

This pull request refactors the handling of XBlock publish state in the course unit workflow, replacing local storage-based refresh triggers with a Redux-based state management approach. It introduces a new setXBlockPublishState reducer and related hook logic, ensuring that the UI updates correctly after discarding changes or saving edits. The changes also improve test coverage for these new behaviors.

State management improvements:

  • Added a new setXBlockPublishState reducer to src/course-unit/data/slice.js to manage the published and hasChanges flags for XBlocks in Redux state.
  • Updated the useCourseUnit hook in src/course-unit/hooks.jsx to include a resetXBlockPublishState function, which dispatches the new action for resetting publish state, and removed the local storage event listener logic. [1] [2]
  • Updated the CourseUnit and XBlockContainerIframe components to use and pass the new resetXBlockPublishState function, ensuring that publish state is reset after discarding changes or completing XBlock editing. [1] [2] [3] [4] [5]

Testing enhancements:

  • Added unit tests for the new reducer in src/course-unit/data/slice.test.js and for the hook logic in src/course-unit/hooks.test.jsx, verifying correct state transitions and hook return values. [1] [2]
  • Added an integration test in src/course-unit/CourseUnit.test.jsx to confirm that the XBlock publish state is reset after discarding changes and the UI updates accordingly.

Code cleanup:

  • Removed legacy local storage refresh logic from the XBlock save workflow and related thunk actions, simplifying the update flow and reducing reliance on browser events. [1] [2]

Supporting information

This PR fixes point 1 in the issue #1893

Testing instructions

Before After
Screencast from 04-07-25 12:01:53.webm Screencast from 04-07-25 11:59:48.webm

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 4, 2025
@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Jul 4, 2025

Thanks for the pull request, @bra-i-am!

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.

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.83%. Comparing base (13c51ce) to head (55775e0).
⚠️ Report is 47 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2257      +/-   ##
==========================================
- Coverage   94.83%   94.83%   -0.01%     
==========================================
  Files        1231     1231              
  Lines       27627    27622       -5     
  Branches     6220     6053     -167     
==========================================
- Hits        26199    26194       -5     
- Misses       1357     1370      +13     
+ Partials       71       58      -13     

☔ 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.

@bra-i-am bra-i-am force-pushed the bc/authoring#1893 branch from 739668d to 7cc6c1f Compare July 4, 2025 20:07
@bra-i-am bra-i-am changed the title Bc/authoring#1893 fix: prevent full iframe reload after xblock edit by refactoring publish state handling Jul 4, 2025
@bra-i-am bra-i-am changed the title fix: prevent full iframe reload after xblock edit by refactoring publish state handling fix: prevent full iframe reload after xblock edition Jul 4, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Jul 15, 2025
@bra-i-am bra-i-am force-pushed the bc/authoring#1893 branch 2 times, most recently from c5bffb2 to e9f9d44 Compare July 30, 2025 20:41
@bra-i-am bra-i-am marked this pull request as ready for review July 30, 2025 21:23
@mphilbrick211 mphilbrick211 moved this from Waiting on Author to Ready for Review in Contributions Sep 16, 2025
@bradenmacdonald
Copy link
Copy Markdown
Contributor

@bra-i-am Sorry for the delay here. I think this looks great. Could you please rebase it so we can make sure it's still working properly with the latest master, and then I'll test and approve it?

@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Oct 8, 2025
@mphilbrick211 mphilbrick211 added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Oct 29, 2025
@bra-i-am
Copy link
Copy Markdown
Contributor Author

@bradenmacdonald, I’m so sorry for the delay, too. I’ve now merged the latest master changes here. I ran some tests, and everything seems to be working well. Please let me know your thoughts.

@bradenmacdonald
Copy link
Copy Markdown
Contributor

@bra-i-am It seems like this PR is very similar to #2600 - how does it compare to that one?

@bradenmacdonald
Copy link
Copy Markdown
Contributor

I have merged #2600 and I believe this issue is now fixed. Please let me know if there are other changes from this PR that you'd like to merge, or if we can close this.

@github-project-automation github-project-automation Bot moved this from In Eng Review to Done in Contributions Dec 10, 2025
@openedx-webhooks openedx-webhooks removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Dec 10, 2025
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

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants