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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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 (d8834a1) to head (66f9553).

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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
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