[Library | new-theme]: full-screen-modal.component.ts & alert.ts: [Bug fix] Added private static counter field to increase on each modal creation and set id according to the counter, to delete from DOM in "modal-container" the destroyed modal.
This commit is contained in:
parent
74bcc96847
commit
cfd44ec96b
|
@ -49,7 +49,9 @@ declare var UIkit: any;
|
|||
* API to an open alert window.
|
||||
*/
|
||||
export class AlertModal {
|
||||
@Input() id: string = "modal";
|
||||
private static MODAL_COUNTER: number = 0;
|
||||
|
||||
id: string = "modal";
|
||||
@Input() classTitle: string = "uk-background-primary-opacity";
|
||||
@Input() classBody: string = "";
|
||||
@Input() large: boolean = false;
|
||||
|
@ -138,6 +140,22 @@ export class AlertModal {
|
|||
constructor() {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
AlertModal.MODAL_COUNTER++;
|
||||
this.id = 'modal-' + AlertModal.MODAL_COUNTER;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if(typeof document !== "undefined") {
|
||||
const element = document.getElementById("modal-container");
|
||||
for (let i = element.childNodes.length - 1; i >= 0; --i) {
|
||||
let child: ChildNode = element.childNodes[i];
|
||||
if (child['id'] == this.id) {
|
||||
child.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens an alert window creating backdrop.
|
||||
|
|
|
@ -51,7 +51,9 @@ declare var ResizeObserver;
|
|||
`
|
||||
})
|
||||
export class FullScreenModalComponent implements AfterViewInit, OnDestroy {
|
||||
@Input() id: string = "fs-modal";
|
||||
private static FS_MODAL_COUNTER: number = 0;
|
||||
|
||||
id: string = "fs-modal";
|
||||
@Input() classTitle: string = "uk-background-primary uk-light";
|
||||
@Input() classBody: string = 'uk-container-large';
|
||||
back: boolean = false;
|
||||
|
@ -79,6 +81,11 @@ export class FullScreenModalComponent implements AfterViewInit, OnDestroy {
|
|||
this.changeHeight();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
FullScreenModalComponent.FS_MODAL_COUNTER++;
|
||||
this.id = 'fs-modal-' + FullScreenModalComponent.FS_MODAL_COUNTER;
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
if(typeof window !== "undefined") {
|
||||
this.observer = new ResizeObserver(entries => {
|
||||
|
@ -102,6 +109,16 @@ export class FullScreenModalComponent implements AfterViewInit, OnDestroy {
|
|||
if(this.observer && this.observer instanceof ResizeObserver) {
|
||||
this.observer.disconnect();
|
||||
}
|
||||
if(typeof document !== "undefined") {
|
||||
const element = document.getElementById("modal-container");
|
||||
for (let i = element.childNodes.length - 1; i >= 0; --i) {
|
||||
let child: ChildNode = element.childNodes[i];
|
||||
if (child['id'] == this.id) {
|
||||
child.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
get isOpen() {
|
||||
|
|
Loading…
Reference in New Issue