Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8ae9dfe

Browse files
committedFeb 24, 2022
fix(collapse): display none
1 parent e323cfe commit 8ae9dfe

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎projects/coreui-angular/src/lib/collapse/collapse.directive.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
AfterViewInit,
23
Directive,
34
DoCheck,
45
ElementRef,
@@ -8,6 +9,7 @@ import {
89
OnChanges,
910
OnDestroy,
1011
Output,
12+
Renderer2,
1113
SimpleChanges
1214
} from '@angular/core';
1315
import { AnimationBuilder, AnimationPlayer, useAnimation } from '@angular/animations';
@@ -21,7 +23,7 @@ import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion';
2123
selector: '[cCollapse]',
2224
exportAs: 'cCollapse'
2325
})
24-
export class CollapseDirective implements OnChanges, OnDestroy, DoCheck {
26+
export class CollapseDirective implements OnChanges, OnDestroy, DoCheck, AfterViewInit {
2527

2628
static ngAcceptInputType_navbar: BooleanInput;
2729

@@ -60,6 +62,7 @@ export class CollapseDirective implements OnChanges, OnDestroy, DoCheck {
6062
get navbar() {
6163
return this._navbar;
6264
}
65+
6366
/**
6467
* @ignore
6568
*/
@@ -79,9 +82,11 @@ export class CollapseDirective implements OnChanges, OnDestroy, DoCheck {
7982

8083
constructor(
8184
private hostElement: ElementRef,
85+
private renderer: Renderer2,
8286
private animationBuilder: AnimationBuilder
8387
) {
8488
this.host = this.hostElement.nativeElement;
89+
this.renderer.setStyle(this.host, 'display', 'none');
8590
}
8691

8792
@HostBinding('class')
@@ -92,6 +97,10 @@ export class CollapseDirective implements OnChanges, OnDestroy, DoCheck {
9297
};
9398
}
9499

100+
ngAfterViewInit(): void {
101+
this.renderer.removeStyle(this.host, 'display');
102+
}
103+
95104
ngOnDestroy(): void {
96105
this.destroyPlayer();
97106
}

0 commit comments

Comments
 (0)
Please sign in to comment.