mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 12:35:07 +00:00
Warn the user about the missing sidebars in registry
+ Check if the sidebar exists before trying to close it
This commit is contained in:
parent
44663342f4
commit
5c66d95951
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user