diff --git a/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts b/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts index 44f53c7eef..7bad8ef96a 100644 --- a/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts +++ b/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts @@ -17,14 +17,12 @@ export class AuthWrapperService { tenantBoxKey = 'Account.TenantBoxComponent'; route: ActivatedRoute; - private _tenantBoxVisible = true; - - private setTenantBoxVisibility = () => { - this._tenantBoxVisible = this.route.snapshot.firstChild.data.tenantBoxVisible ?? true; - }; + get isTenantBoxVisibleForCurrentRoute() { + return this.getMostInnerChild().data.tenantBoxVisible ?? true; + } get isTenantBoxVisible() { - return this._tenantBoxVisible && this.multiTenancy.isTenantBoxVisible; + return this.isTenantBoxVisibleForCurrentRoute && this.multiTenancy.isTenantBoxVisible; } constructor( @@ -33,6 +31,16 @@ export class AuthWrapperService { injector: Injector, ) { this.route = injector.get(ActivatedRoute); - this.setTenantBoxVisibility(); + } + + private getMostInnerChild() { + let child = this.route.snapshot; + let depth = 0; + const depthLimit = 10; + while (child.firstChild && depth < depthLimit) { + child = child.firstChild; + depth++; + } + return child; } }