Skip to content

Commit 71f8e16

Browse files
committed
fix(modal): css .show class not binding to the host, cleanup
1 parent 16a89c7 commit 71f8e16

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

projects/coreui-angular/src/lib/modal/modal/modal.component.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ import { ModalContentComponent } from '../modal-content/modal-content.component'
2828
state(
2929
'visible',
3030
style({
31-
display: 'block'
31+
// display: 'block'
3232
})
3333
),
3434
state(
3535
'hidden',
3636
style({
37-
display: 'none'
37+
// display: 'none'
3838
})
3939
),
4040
transition('visible <=> *', [animate('300ms')])
@@ -147,7 +147,8 @@ export class ModalComponent implements OnInit, OnDestroy {
147147
@ViewChild(ModalContentComponent, { read: ElementRef }) modalContent!: ElementRef;
148148
private activeBackdrop!: any;
149149
private stateToggleSubscription!: Subscription;
150-
private inBoundingClientRect!: boolean;
150+
151+
// private inBoundingClientRect!: boolean;
151152

152153
@HostBinding('class')
153154
get hostClasses(): any {
@@ -196,18 +197,24 @@ export class ModalComponent implements OnInit, OnDestroy {
196197
if (event.toState === 'visible') {
197198
this.renderer.setStyle(this.document.body, 'overflow', 'hidden');
198199
this.renderer.setStyle(this.document.body, 'padding-right', scrollbarWidth);
200+
this.renderer.setStyle(this.hostElement.nativeElement, 'display', 'block');
201+
} else {
202+
if (!this.transition) {
203+
this.renderer.setStyle(this.hostElement.nativeElement, 'display', 'none');
204+
}
199205
}
200206
}
201207

202208
@HostListener('@showHide.done', ['$event'])
203209
animateDone(event: AnimationEvent) {
204210
setTimeout(() => {
205211
if (event.toState === 'hidden') {
212+
this.renderer.setStyle(this.hostElement.nativeElement, 'display', 'none');
206213
this.renderer.removeStyle(this.document.body, 'overflow');
207214
this.renderer.removeStyle(this.document.body, 'padding-right');
208215
}
209-
this.show = this.visible;
210216
});
217+
this.show = this.visible;
211218
}
212219

213220
@HostListener('document:keydown', ['$event'])

0 commit comments

Comments
 (0)