diff --git a/client-frameworks-support/client-support-angular/projects/client-support-angular/src/lib/service/luigi-auto-routing.service.ts b/client-frameworks-support/client-support-angular/projects/client-support-angular/src/lib/service/luigi-auto-routing.service.ts index f98bfe3233..eef794dae2 100644 --- a/client-frameworks-support/client-support-angular/projects/client-support-angular/src/lib/service/luigi-auto-routing.service.ts +++ b/client-frameworks-support/client-support-angular/projects/client-support-angular/src/lib/service/luigi-auto-routing.service.ts @@ -1,6 +1,6 @@ import { Injectable, OnDestroy } from '@angular/core'; import { ActivatedRouteSnapshot, NavigationEnd, ParamMap, Router, RouterEvent, convertToParamMap } from '@angular/router'; -import { linkManager, uxManager } from '@luigi-project/client'; +import { linkManager, uxManager, isLuigiClientInitialized } from '@luigi-project/client'; import { OperatorFunction, Subscription } from 'rxjs'; import { filter } from 'rxjs/operators'; import { LuigiActivatedRouteSnapshotHelper } from '../route/luigi-activated-route-snapshot-helper'; @@ -63,7 +63,7 @@ export class LuigiAutoRoutingService implements OnDestroy { } } } - if (current?.data) { + if (current?.data && isLuigiClientInitialized()) { const ux = uxManager(); let lm = linkManager().withoutSync(); let route: string | undefined; @@ -130,7 +130,7 @@ export class LuigiAutoRoutingService implements OnDestroy { getAllParamsFromParents(current: ActivatedRouteSnapshot): { [key: string]: string } | undefined { let allParams: { [key: string]: string } = {}; - let currentToCheck:ActivatedRouteSnapshot|null = current; + let currentToCheck: ActivatedRouteSnapshot | null = current; while (currentToCheck) { if (currentToCheck.params) { diff --git a/client/src/linkManager.js b/client/src/linkManager.js index a0a2bff102..2412c00f8a 100644 --- a/client/src/linkManager.js +++ b/client/src/linkManager.js @@ -279,8 +279,7 @@ export class linkManager extends LuigiClientBase { * LuigiClient.linkManager().fromClosestContext().navigate('/users/groups/stakeholders') */ fromClosestContext() { - const hasParentNavigationContext = - this.currentContext && this.currentContext.context.parentNavigationContexts.length > 0; + const hasParentNavigationContext = this.currentContext?.context.parentNavigationContexts.length > 0; if (hasParentNavigationContext) { this.options.fromContext = null; this.options.fromClosestContext = true; diff --git a/core/src/services/routing.js b/core/src/services/routing.js index 864ae93f23..6446af82d3 100644 --- a/core/src/services/routing.js +++ b/core/src/services/routing.js @@ -291,8 +291,7 @@ class RoutingClass { this.navigateTo(`${trimmedPathUrl ? `/${trimmedPathUrl}` : ''}/${defaultChildNode}`, { keepBrowserHistory: false }); - // reset comp data - component.set({ navigationPath: [] }); + return false; } else { if (defaultChildNode && pathData.navigationPath.length > 1) { //last path segment was invalid but a default node could be in its place diff --git a/test/e2e-test-application/cypress/e2e/tests/0-js-test-app/js-test-app-navigation.cy.js b/test/e2e-test-application/cypress/e2e/tests/0-js-test-app/js-test-app-navigation.cy.js index bad5cce5eb..ca1092101a 100644 --- a/test/e2e-test-application/cypress/e2e/tests/0-js-test-app/js-test-app-navigation.cy.js +++ b/test/e2e-test-application/cypress/e2e/tests/0-js-test-app/js-test-app-navigation.cy.js @@ -653,4 +653,32 @@ describe('JS-TEST-APP', () => { }); }); }); + + describe('First topNav node has no viewURL and empty children', () => { + let newConfig; + beforeEach(() => { + newConfig = structuredClone(defaultLuigiConfig); + newConfig.navigation.nodes.unshift({ + pathSegment: 'firstnode', + label: 'First Node', + children: [] + }); + }); + it('TopNav nodes should be visible either first node has no view', () => { + cy.visitTestAppLoggedIn('/', newConfig); + cy.expectPathToBe('/firstnode/'); + cy.get('.fd-app__sidebar .fd-nested-list') + .children() + .should('have.length', 0); + cy.get('.fd-shellbar').contains('First Node'); + cy.get('.fd-shellbar') + .contains('Home') + .click(); + cy.expectPathToBe('/home'); + cy.get('.fd-app__sidebar .fd-nested-list') + .children() + .should('have.length', 2); + cy.get('.fd-app__sidebar').contains('Section one'); + }); + }); });