Skip to content

Conversation

@marslanabdulrauf
Copy link
Contributor

Related Ticket (Internal)

https://github.com/mitodl/hq/issues/9166#event-20756793537

Description

This PR:

  1. Fixes auto "You've made some changes" dialogue appearance by fixing the editorType for each content

Steps to Reproduce

  1. Go to any course in Studio
  2. Go to Settings -> Schedule & Details
  3. As soon as the page loads, "You've made some changes" dialogue appears before any changes are made.

Supporting information

It happens because the default course over is in html e.g; <section>About ...</section> and when we serve it as text in TinyMCE Editor it changes the content which triggers the Alert to save the changes.
Adding editorType html fixes the issue however as the field is str in edx-platform we might not get html always.
So a simple utility function is added to analyze and identify editorType from content.

Testing instructions

  1. Checkout master and follow Steps to Reproduce to identify the issue
  2. Checkout to this branch and repeat the steps, Save settings alert shouldn't be visible before any change now

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Avoid propTypes and defaultProps in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Avoid using ../ in import paths. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

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

Thanks for the pull request, @marslanabdulrauf!

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.

@marslanabdulrauf marslanabdulrauf force-pushed the marslan/9166-save-setting-alert branch from 6975c25 to 2489cc7 Compare November 7, 2025 12:12
@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.83%. Comparing base (6afe609) to head (9436441).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #2609    +/-   ##
========================================
  Coverage   94.82%   94.83%            
========================================
  Files        1226     1232     +6     
  Lines       27559    27638    +79     
  Branches     6211     6056   -155     
========================================
+ Hits        26133    26210    +77     
- Misses       1355     1370    +15     
+ 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.

@bradenmacdonald
Copy link
Contributor

Adding editorType html fixes the issue however as the field is str in edx-platform we might not get html always.

I don't quite understand this. When would it not be HTML? And even if it's just a string like "An interesting course." with no HTML, isn't that still HTML in a sense, just without tags?

/**
* Utility functions for detecting content type and
* determining appropriate editor type for TinyMCE editor
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

New files added to this repo should be using TypeScript - please see the "Best practices checklist" in your PR description.

@marslanabdulrauf
Copy link
Contributor Author

Adding editorType html fixes the issue however as the field is str in edx-platform we might not get html always.

I don't quite understand this. When would it not be HTML? And even if it's just a string like "An interesting course." with no HTML, isn't that still HTML in a sense, just without tags?

I wasn't sure if I should hard code the editorType as html although in case of aboutSidebarHtml the name itself says html

I also agree that html editor should also cover simple text, so if you think its ok to hardcode html for editorType I can do that 👍

@bradenmacdonald
Copy link
Contributor

I think it's fine to just hard-code it as HTML, as these are HTML fields. But if you can think of or find any bugs that would result from that, please let me know.

@marslanabdulrauf marslanabdulrauf force-pushed the marslan/9166-save-setting-alert branch 2 times, most recently from fb208bb to c864dea Compare November 10, 2025 09:40
@marslanabdulrauf
Copy link
Contributor Author

While testing with the hardcoded html editor type, I noticed one potential issue:

If we provide plain text like "hello world", the HTML editor automatically wraps it in a <p>hello world</p> tag. This makes the content different from the original text and triggers the “unsaved changes” banner on first load.

We were trying to avoid this same situation when the overview content is actually HTML, but the editor type is set to text.

If we’re certain that all overviews will be HTML-based, we can safely hardcode editorType to html.
However, if there’s still a possibility of having plain-text overviews, we’ll face the same “save alert without actual changes” issue when showing text content in an HTML editor.

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: Needs Triage

Development

Successfully merging this pull request may close these issues.

3 participants