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
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;
}

View File

@ -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',
@ -58,10 +59,13 @@ export class FuseNavbarComponent implements OnInit, OnDestroy
this.router.events.subscribe(
(event) => {
if ( event instanceof NavigationEnd )
{
if ( this.sidebarService.getSidebar('navbar') )
{
this.sidebarService.getSidebar('navbar').close();
}
}
}
);
}