Skip to content

Commit da2462c

Browse files
committed
fix: remove -fixed class on component destroy
1 parent d1694f2 commit da2462c

File tree

5 files changed

+36
-14
lines changed

5 files changed

+36
-14
lines changed

projects/coreui/angular/src/lib/aside/app-aside.component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ElementRef, Input, OnInit } from '@angular/core';
1+
import { Component, ElementRef, Input, OnInit, OnDestroy } from '@angular/core';
22
import { asideMenuCssClasses, Replace } from './../shared/index';
33

44
@Component({
@@ -9,19 +9,24 @@ import { asideMenuCssClasses, Replace } from './../shared/index';
99
</aside>
1010
`
1111
})
12-
export class AppAsideComponent implements OnInit {
12+
export class AppAsideComponent implements OnInit, OnDestroy {
1313
@Input() display: any;
1414
@Input() fixed: boolean;
1515
@Input() offCanvas: boolean;
1616

1717
constructor(private el: ElementRef) {}
1818

19-
ngOnInit() {
19+
ngOnInit(): void {
2020
Replace(this.el);
2121
this.isFixed(this.fixed);
22+
this.isOffCanvas(this.offCanvas);
2223
this.displayBreakpoint(this.display);
2324
}
2425

26+
ngOnDestroy(): void {
27+
document.body.classList.remove('aside-menu-fixed');
28+
}
29+
2530
isFixed(fixed: boolean): void {
2631
if (this.fixed) { document.querySelector('body').classList.add('aside-menu-fixed'); }
2732
}

projects/coreui/angular/src/lib/breadcrumb/app-breadcrumb.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ElementRef, Input, OnInit } from '@angular/core';
1+
import { Component, ElementRef, Input, OnInit, OnDestroy } from '@angular/core';
22
import { Replace } from './../shared';
33
import { AppBreadcrumbService } from './app-breadcrumb.service';
44

@@ -15,7 +15,7 @@ import { AppBreadcrumbService } from './app-breadcrumb.service';
1515
</ng-template>
1616
`
1717
})
18-
export class AppBreadcrumbComponent implements OnInit {
18+
export class AppBreadcrumbComponent implements OnInit, OnDestroy {
1919
@Input() fixed: boolean;
2020
public breadcrumbs;
2121

@@ -27,6 +27,10 @@ export class AppBreadcrumbComponent implements OnInit {
2727
this.breadcrumbs = this.service.breadcrumbs;
2828
}
2929

30+
ngOnDestroy(): void {
31+
document.body.classList.remove('breadcrumb-fixed');
32+
}
33+
3034
isFixed(fixed: boolean): void {
3135
if (this.fixed) { document.querySelector('body').classList.add('breadcrumb-fixed'); }
3236
}

projects/coreui/angular/src/lib/footer/app-footer.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ElementRef, Input, OnInit } from '@angular/core';
1+
import { Component, ElementRef, Input, OnInit, OnDestroy } from '@angular/core';
22
import { Replace } from './../shared';
33

44
@Component({
@@ -9,16 +9,20 @@ import { Replace } from './../shared';
99
</footer>
1010
`
1111
})
12-
export class AppFooterComponent implements OnInit {
12+
export class AppFooterComponent implements OnInit, OnDestroy {
1313
@Input() fixed: boolean;
1414

1515
constructor(private el: ElementRef) {}
1616

17-
ngOnInit() {
17+
ngOnInit(): void {
1818
Replace(this.el);
1919
this.isFixed(this.fixed);
2020
}
2121

22+
ngOnDestroy(): void {
23+
document.body.classList.remove('footer-fixed');
24+
}
25+
2226
isFixed(fixed: boolean): void {
2327
if (this.fixed) { document.querySelector('body').classList.add('footer-fixed'); }
2428
}

projects/coreui/angular/src/lib/header/app-header.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ElementRef, Input, OnInit } from '@angular/core';
1+
import { Component, ElementRef, Input, OnInit, OnDestroy } from '@angular/core';
22
import { Replace } from './../shared';
33

44
@Component({
@@ -51,7 +51,7 @@ import { Replace } from './../shared';
5151
</header>
5252
`
5353
})
54-
export class AppHeaderComponent implements OnInit {
54+
export class AppHeaderComponent implements OnInit, OnDestroy {
5555

5656
@Input() fixed: boolean;
5757

@@ -67,11 +67,15 @@ export class AppHeaderComponent implements OnInit {
6767

6868
constructor(private el: ElementRef) {}
6969

70-
ngOnInit() {
70+
ngOnInit(): void {
7171
Replace(this.el);
7272
this.isFixed(this.fixed);
7373
}
7474

75+
ngOnDestroy(): void {
76+
document.body.classList.remove('header-fixed');
77+
}
78+
7579
isFixed(fixed: boolean): void {
7680
if (this.fixed) { document.querySelector('body').classList.add('header-fixed'); }
7781
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Component, Input, HostBinding, OnInit } from '@angular/core';
1+
import { Component, Input, HostBinding, OnInit, OnDestroy } from '@angular/core';
22
import { sidebarCssClasses } from './../shared';
33

44
@Component({
55
selector: 'app-sidebar',
66
template: `<ng-content></ng-content>`
77
})
8-
export class AppSidebarComponent implements OnInit {
8+
export class AppSidebarComponent implements OnInit, OnDestroy {
99
@Input() compact: boolean;
1010
@Input() display: any;
1111
@Input() fixed: boolean;
@@ -16,14 +16,18 @@ export class AppSidebarComponent implements OnInit {
1616

1717
constructor() {}
1818

19-
ngOnInit() {
19+
ngOnInit(): void {
2020
this.displayBreakpoint(this.display);
2121
this.isCompact(this.compact);
2222
this.isFixed(this.fixed);
2323
this.isMinimized(this.minimized);
2424
this.isOffCanvas(this.offCanvas);
2525
}
2626

27+
ngOnDestroy(): void {
28+
document.body.classList.remove('sidebar-fixed');
29+
}
30+
2731
isCompact(compact: boolean): void {
2832
if (this.compact) { document.querySelector('body').classList.add('sidebar-compact'); }
2933
}
@@ -41,6 +45,7 @@ export class AppSidebarComponent implements OnInit {
4145
}
4246

4347
fixedPosition(fixed: boolean): void {
48+
console.warn('fixedPosition() is deprecated, use isFixed() instead')
4449
if (this.fixed) { document.querySelector('body').classList.add('sidebar-fixed'); }
4550
}
4651

0 commit comments

Comments
 (0)