You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We see here that the link on the image is suppressed if there is a non-empty title or there are teaser actions.
However, if we look at the component html teaser/v2/teaser/teaser.html we see the following:
Here we see that the outer anchor is unwrapped (removed) if the link is invalid or there are CTA links.
The problem is that the logic for if the image should be linked, and the logic for if the entire Teaser should be linked are not in agreement. This can lead to situations where both the Teaser and the Image are linked - which causes broken HTML because links are not allowed inside of links.
The solution to this is to make sure that the case for when an image is linked and when the teaser is linked are mutually exclusive.
I'm not entirely sure what the blankness of the title has to do with if the image should be linked or not, removing that condition from the V2 model implementation would probably resolve the issue.
A more sustainable approach, that would require a change to the model interface, would be moving the logic for the data-sly-unwrap into a method called something like boolean getLinkTeaser() and then the HTL becomes data-sly-unwrap="${!teaser.linkTeaser}" and then this method can be re-used inside models initImage() method as such:
if (this.getLinkTeaser()) {
overriddenImageResourceProperties.put(Teaser.PN_IMAGE_LINK_HIDDEN, Boolean.TRUE.toString());
}
Bug Report
Current Behavior
When a teaser has:
then the resulting HTML is invalid because of nested anchor tags - which is prohibited.
Expected behavior/code
The component should not create HTML that is invalid.
Environment
Possible Solution
The issue stems from the
v2/TeaserImpl.java
modelinitImage()
method:We see here that the link on the image is suppressed if there is a non-empty title or there are teaser actions.
However, if we look at the component html
teaser/v2/teaser/teaser.html
we see the following:Here we see that the outer anchor is unwrapped (removed) if the link is invalid or there are CTA links.
The problem is that the logic for if the image should be linked, and the logic for if the entire Teaser should be linked are not in agreement. This can lead to situations where both the Teaser and the Image are linked - which causes broken HTML because links are not allowed inside of links.
The solution to this is to make sure that the case for when an image is linked and when the teaser is linked are mutually exclusive.
I'm not entirely sure what the blankness of the title has to do with if the image should be linked or not, removing that condition from the V2 model implementation would probably resolve the issue.
A more sustainable approach, that would require a change to the model interface, would be moving the logic for the
data-sly-unwrap
into a method called something likeboolean getLinkTeaser()
and then the HTL becomesdata-sly-unwrap="${!teaser.linkTeaser}"
and then this method can be re-used inside modelsinitImage()
method as such:or, better yet
The text was updated successfully, but these errors were encountered: