aem-core-wcm-components icon indicating copy to clipboard operation
aem-core-wcm-components copied to clipboard

Content Language for Breadcrumb links referring to custom/unknown page property?

Open HitmanInWis opened this issue 1 year ago • 2 comments

Bug present as of version: 2.25.5-SNAPSHOT

https://github.com/adobe/aem-core-wcm-components/pull/2725/files added a language attribute to Breadcrumb links. However, as best I can tell the contentLang property being referred to in breadcrumb.html is not a standard page property.

<sly data-sly-set.lang="${navItem.page.properties.contentLang}"/>

Also, if it is important to set language on Breadcrumb links, shouldn't we be doing the same for all links?

HitmanInWis avatar Jul 12 '24 15:07 HitmanInWis

I agree with this. The contentLang page property doesn't appear anywhere.

The pull request says when a custom language is defined in advanced property of the page. However, when a language is selected in the page properties dialog it is stored under the property name jcr:language.

Additional Issues:

  • this change uses the method NavigationItem#getPage() - which is deprecated.
  • the page properties are not serialized in the JSON model, and so this information can't be used in any headless setup.
  • directly referencing a page property on the target page misses that the language might be defined on an ancestor of the target page, or as part of the page path.
  • this is now the only component that directly references page or component properties in the HTL instead of via the model.

I think the proper solution to this issue would be to get the language information in the model (or directly in the LinkBuilder) using either the LanguageManager or Page.getLanguage() and then expose that information as part of the Link and/or it's HTML attributes.

Adding this functionality directly to the LinkBuilder would make it global for any page-based link. One concern there is that the hreflang can reasonably be set on any link (because it refers to the language of the target page content), but the lang attribute should only be set when the text of the link is in a different language - this would likely be true in any situation where the link text is derived from the target page.

ky940819 avatar Aug 08 '24 15:08 ky940819

Pinging @LSantha into the conversation as he reviewed and merged the PR from @renow-luxembourg

vladbailescu avatar Aug 08 '24 16:08 vladbailescu