From da831893de8e56072c0e3bebe0128b5f21309b55 Mon Sep 17 00:00:00 2001 From: mohit-nagaraj Date: Tue, 8 Oct 2024 07:37:35 +0530 Subject: [PATCH] fix scroll in notfication --- src/components/NotificationDialog.vue | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index b34b5f8ad..fd9042a5e 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -226,24 +226,20 @@ export default { this.notification.name = this.getUniqueDefaultName(to); } }, + watch: { $route(to, from) { - if (this.modal) { - this.modal.hide(); - } + this.cleanupModal(); } }, + }, mounted() { this.modal = new Modal(this.$refs.modal); }, beforeUnmount() { - if (this.modal) { - this.modal.dispose(); - } + this.cleanupModal(); }, beforeRouteLeave(to, from, next) { - if (this.modal) { - this.modal.hide(); - } + this.cleanupModal(); next(); }, methods: { @@ -350,6 +346,20 @@ export default { }); } while (this.$root.notificationList.find(it => it.name === name)); return name; + }, + + /** + * 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 = ''; } }, };