Warn the user about the missing sidebars in registry

+ Check if the sidebar exists before trying to close it
This commit is contained in:
Sercan Yemen 2018-04-04 13:37:59 +03:00
parent 44663342f4
commit 5c66d95951
2 changed files with 8 additions and 3 deletions

View File

@ -46,7 +46,7 @@ export class FuseSidebarService
// Check if the sidebar exists // Check if the sidebar exists
if ( !this._registry[key] ) 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 // Unregister the sidebar
@ -57,13 +57,14 @@ export class FuseSidebarService
* Return the sidebar with the given key * Return the sidebar with the given key
* *
* @param key * @param key
* @returns {FuseSidebarComponent}
*/ */
getSidebar(key): FuseSidebarComponent getSidebar(key): FuseSidebarComponent
{ {
// Check if the sidebar exists // Check if the sidebar exists
if ( !this._registry[key] ) 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; return;
} }

View File

@ -7,6 +7,7 @@ import { FuseSidebarService } from '@fuse/components/sidebar/sidebar.service';
import { navigation } from 'app/navigation/navigation'; import { navigation } from 'app/navigation/navigation';
import { FuseNavigationService } from '@fuse/components/navigation/navigation.service'; import { FuseNavigationService } from '@fuse/components/navigation/navigation.service';
import { FuseSidebarComponent } from '@fuse/components/sidebar/sidebar.component';
@Component({ @Component({
selector : 'fuse-navbar', selector : 'fuse-navbar',
@ -59,7 +60,10 @@ export class FuseNavbarComponent implements OnInit, OnDestroy
(event) => { (event) => {
if ( event instanceof NavigationEnd ) if ( event instanceof NavigationEnd )
{ {
this.sidebarService.getSidebar('navbar').close(); if ( this.sidebarService.getSidebar('navbar') )
{
this.sidebarService.getSidebar('navbar').close();
}
} }
} }
); );