Skip to content

Commit

Permalink
fix(primeng/p-blockui): add test if mask exists before trying to inte…
Browse files Browse the repository at this point in the history
…ract with it when blockUi component is been destroyed
  • Loading branch information
maximegris committed Nov 18, 2022
1 parent 69ba97e commit 519a769
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/app/components/blockui/blockui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,19 @@ export class BlockUI implements AfterViewInit, OnDestroy {

unblock() {
this.animationEndListener = this.destroyModal.bind(this);
this.mask.nativeElement.addEventListener('animationend', this.animationEndListener);
DomHandler.addClass(this.mask.nativeElement, 'p-component-overlay-leave');
if(this.mask) {
this.mask.nativeElement.addEventListener('animationend', this.animationEndListener);
DomHandler.addClass(this.mask.nativeElement, 'p-component-overlay-leave');
}
}

destroyModal() {
this._blocked = false;
DomHandler.removeClass(this.mask.nativeElement, 'p-component-overlay-leave');
ZIndexUtils.clear(this.mask.nativeElement);
this.el.nativeElement.appendChild(this.mask.nativeElement);
if(this.mask) {
DomHandler.removeClass(this.mask.nativeElement, 'p-component-overlay-leave');
ZIndexUtils.clear(this.mask.nativeElement);
this.el.nativeElement.appendChild(this.mask.nativeElement);
}
this.unbindAnimationEndListener();
this.cd.markForCheck();
}
Expand Down

0 comments on commit 519a769

Please sign in to comment.