From 360868d4e69c599a4aea0da2a426784a4831ebf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87etin?= <69278826+cetincakiroglu@users.noreply.github.com> Date: Mon, 25 Sep 2023 16:11:59 +0300 Subject: [PATCH] Fixes #13734 - Add missing class to prevent scroll --- src/app/components/blockui/blockui.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/components/blockui/blockui.ts b/src/app/components/blockui/blockui.ts index 218d2572a81..03668b102cc 100755 --- a/src/app/components/blockui/blockui.ts +++ b/src/app/components/blockui/blockui.ts @@ -107,6 +107,8 @@ export class BlockUI implements AfterViewInit, OnDestroy { this.target.getBlockableElement().style.position = 'relative'; } else { this.renderer.appendChild(this.document.body, (this.mask as ElementRef).nativeElement); + DomHandler.addClass(this.document.body, 'p-overflow-hidden'); + this.document.body.style.setProperty('--scrollbar-width', DomHandler.calculateScrollbarWidth() + 'px'); } if (this.autoZIndex) { @@ -124,9 +126,11 @@ export class BlockUI implements AfterViewInit, OnDestroy { destroyModal() { this._blocked = false; if (this.mask) { - DomHandler.removeClass(this.mask.nativeElement, 'p-component-overlay-leave'); ZIndexUtils.clear(this.mask.nativeElement); - this.renderer.appendChild(this.el.nativeElement, this.mask.nativeElement); + DomHandler.removeClass(this.mask.nativeElement, 'p-component-overlay-leave'); + this.renderer.removeChild(this.el.nativeElement, this.mask.nativeElement); + DomHandler.removeClass(this.document.body, 'p-overflow-hidden'); + this.document.body.style.removeProperty('--scrollbar-width'); } this.unbindAnimationEndListener(); this.cd.markForCheck();