adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
746 stars 753 forks source link

Language Navigation in Live Copy using incorrect root page #2867

Open HitmanInWis opened 1 month ago

HitmanInWis commented 1 month ago

When a Language Navigation component is in a template structure, or in a blueprint XF inherited to a live copy site, the Navigation Root isn't updated to the Live Copy site, and thus the nav links/languages point to the blueprint site rather than the live copy.

Language Navigation should operate similar to the Navigation component, which takes the configured Navigation Root page and updates it to the current site path before calculating nav links.

The update would be made to LanguageNavigationImpl, using similar logic as NavigationImpl, changing:

    public List<NavigationItem> getItems() {
        if (items == null) {
            PageManager pageManager = currentPage.getPageManager();
            rootPage = pageManager.getPage(navigationRoot);
            if (rootPage != null) {

to

    public List<NavigationItem> getItems() {
        if (items == null) {
            PageManager pageManager = currentPage.getPageManager();
            rootPage = pageManager.getPage(navigationRoot);
            rootPage = LocalizationUtils.getLocalPage(rootPage,
                    this.currentPage,
                    this.request.getResourceResolver(),
                    this.languageManager,
                    this.relationshipManager)
                .orElseGet(() -> rootPage);
            if (rootPage != null) {