Skip to content

Conversation

@PKulkoRaccoonGang
Copy link
Contributor

@PKulkoRaccoonGang PKulkoRaccoonGang commented Oct 27, 2025

Description

Added a content check before rendering the xblock. If the about section is empty or contains only whitespace, return an empty string instead of rendering the xblock.

Useful information to include:

Supporting information

Empty about_sidebar_html (and other about sections) were generating unnecessary xblock wrapper divs even when they contained no content, causing extra DOM elements and potential styling issues.

Initial setup

Go to openedx/frontend-app-catalog#38 and follow all the steps to set up and run the new Catalog MFE.

Testing instructions

  1. Open the new Catalog MFE Course About page and the Schedule and Details page.
  2. Add any content to the Course About Sidebar HTML section and save it.
  3. Verify that the content is displayed correctly on both the updated MFE page and the legacy page.
  4. Make sure the content is wrapped in the xblock wrapper.
  5. Go back to the Schedule and Details page and remove the content from the Course About Sidebar HTML section.
  6. Confirm that the about_sidebar_html field returns an empty string without xblock stuff.

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

openedx-webhooks commented Oct 27, 2025

Thanks for the pull request, @PKulkoRaccoonGang!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

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 Oct 27, 2025
@PKulkoRaccoonGang PKulkoRaccoonGang force-pushed the Peter_Kulko/optimize-about-rendering branch from ce199a1 to 0643407 Compare October 27, 2025 07:34
@PKulkoRaccoonGang PKulkoRaccoonGang force-pushed the Peter_Kulko/optimize-about-rendering branch from 0643407 to a136889 Compare October 27, 2025 07:53
@PKulkoRaccoonGang PKulkoRaccoonGang changed the title feat: use direct data access for course about sections feat: Prevent empty wrapper divs for about sections with no content Oct 27, 2025
@PKulkoRaccoonGang PKulkoRaccoonGang self-assigned this Oct 27, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Oct 27, 2025
# Only render XBlock if content exists to avoid generating empty wrapper divs
content = about_block.data
if content and content.strip():
html = about_block.render(STUDENT_VIEW).content
Copy link
Contributor

@ormsbee ormsbee Oct 27, 2025

Choose a reason for hiding this comment

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

I've noticed that if you delete everything in the HTML editor for the course overview, it still leaves <p>&nbsp;</p>. It might be worth special casing this to be equivalent to blank.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching that! I’ve added an is_empty_html function to handle cases with empty tags that might get saved on the frontend.

I also think this should ideally be validated on the Authoring MFE side. I’m planning to open a separate issue for that.

@PKulkoRaccoonGang PKulkoRaccoonGang marked this pull request as ready for review October 28, 2025 15:13
@PKulkoRaccoonGang PKulkoRaccoonGang force-pushed the Peter_Kulko/optimize-about-rendering branch 2 times, most recently from 5d6642d to 1768217 Compare October 28, 2025 16:06
@PKulkoRaccoonGang PKulkoRaccoonGang force-pushed the Peter_Kulko/optimize-about-rendering branch from 1768217 to 298328b Compare October 28, 2025 16:34
@ormsbee
Copy link
Contributor

ormsbee commented Oct 28, 2025

We'll want to check out APM traces of this on the sandbox after it lands just to make sure the HTML parsing isn't getting too expensive on an endpoint that will likely get hit a lot. I honestly don't expect this to be a problem--just something to keep in the back of our minds.

@ormsbee ormsbee merged commit 2a473cf into openedx:master Oct 29, 2025
49 checks passed
@github-project-automation github-project-automation bot moved this from Waiting on Author to Done in Contributions Oct 29, 2025
haftamuk pushed a commit to haftamuk/edx-platform that referenced this pull request Nov 3, 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

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants