Skip to content
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

SITES-28693 - Teaser Component Renders Broken HTML When Title is Empty #2921

Merged
merged 6 commits into from
Mar 6, 2025

Conversation

vladbailescu
Copy link
Member

  • Updated teaser to only allow image to render links if all other elements are empty (pre-title, title, description, actions), in which case it will unwrap the general link on the teaser content.

Fixes #2660

* Updated teaser to only allow image to render links if all other elements are empty (pre-title, title, description, actions), in which case it will unwrap the general link on the teaser content.

Fixes #2660
@vladbailescu vladbailescu requested a review from LSantha February 14, 2025 15:27
Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.14%. Comparing base (ace15d9) to head (10b90e3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #2921   +/-   ##
=========================================
  Coverage     87.14%   87.14%           
- Complexity     2697     2698    +1     
=========================================
  Files           235      235           
  Lines          7202     7202           
  Branches       1104     1104           
=========================================
  Hits           6276     6276           
  Misses          366      366           
  Partials        560      560           

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

@LSantha
Copy link
Contributor

LSantha commented Feb 19, 2025

@vladbailescu , it looks like, when image + valid link is set and pre-title, title, description, actions are blank then we still have nested anchors.

@@ -81,7 +81,8 @@ protected void initImage() {
overriddenImageResourceProperties.put(Teaser.PN_ACTIONS_ENABLED, Boolean.valueOf(actionsEnabled).toString());
overriddenImageResourceProperties.put(PN_ID, String.join(ID_SEPARATOR, this.getId(), IMAGE_ID_PREFIX));

if (StringUtils.isNotEmpty(getTitle()) || getTeaserActions().size() > 0) {
// Only allow image to render links if all other elements are empty
if (!(StringUtils.isAllBlank(getTitle(), getPretitle(), getDescription()) && getTeaserActions().isEmpty())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need '||' here instead of '&&" as before.

Copy link
Member Author

Choose a reason for hiding this comment

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

I double-checked and I think this is correct:
image

Copy link
Member Author

Choose a reason for hiding this comment

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

I will prepare some test content and an IT nevertheless

Copy link

sonarqubecloud bot commented Mar 6, 2025

Copy link
Contributor

@LSantha LSantha left a comment

Choose a reason for hiding this comment

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

LGTM.

@vladbailescu vladbailescu merged commit e186da8 into main Mar 6, 2025
16 checks passed
@vladbailescu vladbailescu deleted the issue/2660 branch March 6, 2025 14:10
@LSantha LSantha added this to the 2.28.0 milestone Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Teaser V2] Invalid HTML if teaser has link + image but no Title
3 participants