-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: Prevent empty wrapper divs for about sections with no content #37551
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
feat: Prevent empty wrapper divs for about sections with no content #37551
Conversation
|
Thanks for the pull request, @PKulkoRaccoonGang! 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. DetailsWhere 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. |
ce199a1 to
0643407
Compare
0643407 to
a136889
Compare
| # 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 |
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.
I've noticed that if you delete everything in the HTML editor for the course overview, it still leaves <p> </p>. It might be worth special casing this to be equivalent to blank.
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.
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.
5d6642d to
1768217
Compare
1768217 to
298328b
Compare
|
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. |
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
about_sidebar_htmlfield returns an empty string without xblock stuff.