From 45b6c8a91d084695b3ff1e144129682cd9f8161e Mon Sep 17 00:00:00 2001 From: mohit-nagaraj Date: Tue, 8 Oct 2024 07:33:18 +0530 Subject: [PATCH] Fix scroll lock when the modal is opened, its sets overflow hidden, remove this style so as to unfreeze it --- src/components/ProxyDialog.vue | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/components/ProxyDialog.vue b/src/components/ProxyDialog.vue index 62eb6f2bc..718bdb5f5 100644 --- a/src/components/ProxyDialog.vue +++ b/src/components/ProxyDialog.vue @@ -131,24 +131,18 @@ export default { }, beforeRouteLeave(to, from, next) { - if (this.modal) { - this.modal.hide(); - } + this.cleanupModal(); next(); }, watch: { $route(to, from) { - if (this.modal) { - this.modal.hide(); - } + this.cleanupModal(); } }, beforeUnmount() { - if (this.modal) { - this.modal.dispose(); - } + this.cleanupModal(); }, methods: { @@ -230,6 +224,20 @@ export default { } }); }, + + /** + * Clean up modal and restore scroll behavior + * @returns {void} + */ + cleanupModal() { + if (this.modal) { + this.modal.hide(); + this.modal.dispose(); + } + document.body.classList.remove('modal-open'); + document.body.style.paddingRight = ''; + document.body.style.overflow = ''; + } }, };