From 519a7690c6b475702472a0a8b28679f4886fcfde Mon Sep 17 00:00:00 2001 From: Maxime GRIS Date: Fri, 18 Nov 2022 15:46:30 +0100 Subject: [PATCH] fix(primeng/p-blockui): add test if mask exists before trying to interact with it when blockUi component is been destroyed --- src/app/components/blockui/blockui.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/components/blockui/blockui.ts b/src/app/components/blockui/blockui.ts index 56d2da1c7ea..340859219c7 100755 --- a/src/app/components/blockui/blockui.ts +++ b/src/app/components/blockui/blockui.ts @@ -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(); }