Skip to content

Commit 13f6548

Browse files
committed
refactor(sidebar-nav): minor fixes
1 parent d05d40a commit 13f6548

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

projects/coreui-angular/src/lib/sidebar/sidebar-nav/sidebar-nav-link.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class SidebarNavLinkComponent implements OnInit, OnDestroy {
8585
this.url =
8686
typeof this.item.url === 'string'
8787
? this.item.url
88-
: this.router.serializeUrl(this.router.createUrlTree(this.item.url as any[]));
88+
: this.router.serializeUrl(this.router.createUrlTree((this.item.url as any[]) ?? ['']));
8989
this.linkType = this.getLinkType();
9090
this.href = this.isDisabled() ? '' : this.item.href || this.url;
9191
this.linkActive = this.router.url.split(/[?#(;]/)[0] === this.href.split(/[?#(;]/)[0];
@@ -110,7 +110,7 @@ export class SidebarNavLinkComponent implements OnInit, OnDestroy {
110110

111111
public isExternalLink(): boolean {
112112
const linkPath = Array.isArray(this.item.url) ? this.item.url[0] : this.item.url;
113-
return !!this.item.href || linkPath.substring(0, 4) === 'http';
113+
return !!this.item.href || linkPath?.substring(0, 4) === 'http';
114114
}
115115

116116
linkClicked(): void {

projects/coreui-angular/src/lib/sidebar/sidebar-nav/sidebar-nav.component.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,22 +160,26 @@ export class SidebarNavGroupComponent implements OnInit, OnDestroy {
160160

161161
onAnimationStart($event: AnimationEvent) {
162162
this.display = { display: 'block' };
163-
if ($event.toState === 'open') {
164-
const host = this.sidebarNav.nativeElement;
165-
this.renderer.setStyle(host, 'height', `${host['scrollHeight']}px`);
166-
}
163+
setTimeout(() => {
164+
const host = this.sidebarNav?.nativeElement;
165+
if ($event.toState === 'open' && host) {
166+
this.renderer.setStyle(host, 'height', `${host['scrollHeight']}px`);
167+
}
168+
});
167169
}
168170

169171
onAnimationDone($event: AnimationEvent) {
170-
if ($event.toState === 'open') {
171-
const host = this.sidebarNav.nativeElement;
172-
this.renderer.setStyle(host, 'height', 'auto');
173-
}
174-
if ($event.toState === 'closed') {
175-
setTimeout(() => {
176-
this.display = null;
177-
});
178-
}
172+
setTimeout(() => {
173+
const host = this.sidebarNav?.nativeElement;
174+
if ($event.toState === 'open' && host) {
175+
this.renderer.setStyle(host, 'height', 'auto');
176+
}
177+
if ($event.toState === 'closed') {
178+
setTimeout(() => {
179+
this.display = null;
180+
});
181+
}
182+
});
179183
}
180184
}
181185

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy