From e204de32f41a41a1b942e069c453fbc082a3b053 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Mon, 25 Sep 2023 10:30:34 +0100 Subject: [PATCH] Fixed #882 - Dialog component scrollbar shift --- components/lib/base/Base.js | 1 + components/lib/dialog/Dialog.vue | 2 ++ 2 files changed, 3 insertions(+) diff --git a/components/lib/base/Base.js b/components/lib/base/Base.js index df8d053fe..8798c8fdb 100644 --- a/components/lib/base/Base.js +++ b/components/lib/base/Base.js @@ -19,6 +19,7 @@ const styles = ` .p-overflow-hidden { overflow: hidden; + padding-right: var(--scrollbar-width); } `; diff --git a/components/lib/dialog/Dialog.vue b/components/lib/dialog/Dialog.vue index fcb1e826d..84204b83d 100755 --- a/components/lib/dialog/Dialog.vue +++ b/components/lib/dialog/Dialog.vue @@ -213,11 +213,13 @@ export default { enableDocumentSettings() { if (this.modal || (!this.modal && this.blockScroll) || (this.maximizable && this.maximized)) { DomHandler.addClass(document.body, 'p-overflow-hidden'); + document.body.style.setProperty('--scrollbar-width', DomHandler.calculateScrollbarWidth() + 'px'); } }, unbindDocumentState() { if (this.modal || (!this.modal && this.blockScroll) || (this.maximizable && this.maximized)) { DomHandler.removeClass(document.body, 'p-overflow-hidden'); + document.body.style.removeProperty('--scrollbar-width'); } }, onKeyDown(event) {