Skip to content

Commit

Permalink
Merge pull request #12255 from maximegris/fix-blockui-destroy-mask-npe
Browse files Browse the repository at this point in the history
fix(primeng/p-blockui): Check if mask exists before trying to interact with it when blockUi component is been destroyed
  • Loading branch information
cetincakiroglu committed Nov 28, 2022
2 parents 94944c6 + 519a769 commit 89b4498
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 89b4498

Please sign in to comment.