From 99441eb233c645c5b6a1ef2266beeb75d42ab079 Mon Sep 17 00:00:00 2001 From: KumJungMin Date: Sat, 8 Jun 2024 21:22:12 +0900 Subject: [PATCH 1/3] fix: block duplicate block content --- components/lib/utils/DomHandler.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/lib/utils/DomHandler.js b/components/lib/utils/DomHandler.js index 98aeb7f335..fa6bb74b93 100755 --- a/components/lib/utils/DomHandler.js +++ b/components/lib/utils/DomHandler.js @@ -849,11 +849,19 @@ export default { }, blockBodyScroll(className = 'p-overflow-hidden') { + const isBlocked = document.body.classList.contains(className); + + if (isBlocked) return; + document.body.style.setProperty('--scrollbar-width', this.calculateBodyScrollbarWidth() + 'px'); this.addClass(document.body, className); }, unblockBodyScroll(className = 'p-overflow-hidden') { + const isBlocked = document.body.classList.contains(className); + + if (!isBlocked) return; + document.body.style.removeProperty('--scrollbar-width'); this.removeClass(document.body, className); } From bfb46909ba42b7d43e8760184d5d2499100ddcc6 Mon Sep 17 00:00:00 2001 From: KumJungMin Date: Sat, 8 Jun 2024 21:27:55 +0900 Subject: [PATCH 2/3] fix: prevent unblock of scroll when even one modal is open --- components/lib/dialog/Dialog.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/lib/dialog/Dialog.vue b/components/lib/dialog/Dialog.vue index 762db37f99..2fe4c99875 100755 --- a/components/lib/dialog/Dialog.vue +++ b/components/lib/dialog/Dialog.vue @@ -211,7 +211,7 @@ export default { } if (!this.modal) { - this.maximized ? DomHandler.blockBodyScroll() : DomHandler.unblockBodyScroll(); + this.maximized ? DomHandler.blockBodyScroll() : this.unblockScroll(); } }, enableDocumentSettings() { @@ -221,9 +221,16 @@ export default { }, unbindDocumentState() { if (this.modal || (!this.modal && this.blockScroll) || (this.maximizable && this.maximized)) { - DomHandler.unblockBodyScroll(); + this.unblockScroll(); } }, + unblockScroll() { + // TODO: refactor this to use a better way to check if there are any dialogs opened + const dialogMap = this.$parentInstance.instanceMap; + const isDialogsOpened = Object.values(dialogMap).some((instance) => instance.visible); + + if (!isDialogsOpened) DomHandler.unblockBodyScroll(); + }, onKeyDown(event) { if (event.code === 'Escape' && this.closeOnEscape) { this.close(); From 1977bfdeb16de99eeaf81bf860e28422d843893a Mon Sep 17 00:00:00 2001 From: KumJungMin Date: Sat, 8 Jun 2024 21:36:27 +0900 Subject: [PATCH 3/3] fix: fix instanceMap undefined error --- components/lib/dialog/Dialog.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/lib/dialog/Dialog.vue b/components/lib/dialog/Dialog.vue index 2fe4c99875..87a1fba492 100755 --- a/components/lib/dialog/Dialog.vue +++ b/components/lib/dialog/Dialog.vue @@ -226,7 +226,7 @@ export default { }, unblockScroll() { // TODO: refactor this to use a better way to check if there are any dialogs opened - const dialogMap = this.$parentInstance.instanceMap; + const dialogMap = this.$parentInstance?.instanceMap || {}; const isDialogsOpened = Object.values(dialogMap).some((instance) => instance.visible); if (!isDialogsOpened) DomHandler.unblockBodyScroll();