From 5c66d9595196d1498f7c0629ad73c7d515ab1ba3 Mon Sep 17 00:00:00 2001 From: Sercan Yemen Date: Wed, 4 Apr 2018 13:37:59 +0300 Subject: [PATCH] Warn the user about the missing sidebars in registry + Check if the sidebar exists before trying to close it --- src/@fuse/components/sidebar/sidebar.service.ts | 5 +++-- src/app/main/navbar/navbar.component.ts | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/@fuse/components/sidebar/sidebar.service.ts b/src/@fuse/components/sidebar/sidebar.service.ts index c101b56c..180e15ec 100644 --- a/src/@fuse/components/sidebar/sidebar.service.ts +++ b/src/@fuse/components/sidebar/sidebar.service.ts @@ -46,7 +46,7 @@ export class FuseSidebarService // Check if the sidebar exists if ( !this._registry[key] ) { - console.error(`The sidebar with the key '${key}' doesn't exist in the registry.`); + console.warn(`The sidebar with the key '${key}' doesn't exist in the registry.`); } // Unregister the sidebar @@ -57,13 +57,14 @@ export class FuseSidebarService * Return the sidebar with the given key * * @param key + * @returns {FuseSidebarComponent} */ getSidebar(key): FuseSidebarComponent { // Check if the sidebar exists if ( !this._registry[key] ) { - console.error(`The sidebar with the key '${key}' doesn't exist in the registry.`); + console.warn(`The sidebar with the key '${key}' doesn't exist in the registry.`); return; } diff --git a/src/app/main/navbar/navbar.component.ts b/src/app/main/navbar/navbar.component.ts index 7889d66d..2055e6cc 100644 --- a/src/app/main/navbar/navbar.component.ts +++ b/src/app/main/navbar/navbar.component.ts @@ -7,6 +7,7 @@ import { FuseSidebarService } from '@fuse/components/sidebar/sidebar.service'; import { navigation } from 'app/navigation/navigation'; import { FuseNavigationService } from '@fuse/components/navigation/navigation.service'; +import { FuseSidebarComponent } from '@fuse/components/sidebar/sidebar.component'; @Component({ selector : 'fuse-navbar', @@ -59,7 +60,10 @@ export class FuseNavbarComponent implements OnInit, OnDestroy (event) => { if ( event instanceof NavigationEnd ) { - this.sidebarService.getSidebar('navbar').close(); + if ( this.sidebarService.getSidebar('navbar') ) + { + this.sidebarService.getSidebar('navbar').close(); + } } } );