From e2ce0e38a68a7eb8432e98993e8ec2b411efe45e Mon Sep 17 00:00:00 2001 From: mohit-nagaraj Date: Tue, 8 Oct 2024 08:23:07 +0530 Subject: [PATCH] update --- src/components/CreateGroupDialog.vue | 28 +++++++++++++++++++++++++ src/components/NotificationDialog.vue | 7 +++++-- src/components/ProxyDialog.vue | 7 +++++-- src/components/TagsManager.vue | 30 +++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/src/components/CreateGroupDialog.vue b/src/components/CreateGroupDialog.vue index ba7fe6eb7..711369755 100644 --- a/src/components/CreateGroupDialog.vue +++ b/src/components/CreateGroupDialog.vue @@ -42,6 +42,18 @@ export default { mounted() { this.modal = new Modal(this.$refs.modal); }, + watch: { + $route(to, from) { + this.cleanupModal(); + } + }, + beforeUnmount() { + this.cleanupModal(); + }, + beforeRouteLeave(to, from, next) { + this.cleanupModal(); + next(); + }, methods: { /** * Show the confirm dialog @@ -58,6 +70,22 @@ export default { this.$emit("added", this.groupName); this.modal.hide(); }, + /** + * Clean up modal and restore scroll behavior + * @returns {void} + */ + cleanupModal() { + if (this.modal) { + try { + this.modal.hide(); + } catch (e) { + console.warn("Modal hide failed:", e); + } + } + document.body.classList.remove('modal-open'); + document.body.style.paddingRight = ''; + document.body.style.overflow = ''; + } }, }; diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index fd9042a5e..41b179780 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -354,8 +354,11 @@ export default { */ cleanupModal() { if (this.modal) { - this.modal.hide(); - this.modal.dispose(); + try { + this.modal.hide(); + } catch (e) { + console.warn("Modal hide failed:", e); + } } document.body.classList.remove('modal-open'); document.body.style.paddingRight = ''; diff --git a/src/components/ProxyDialog.vue b/src/components/ProxyDialog.vue index 718bdb5f5..35c752a1b 100644 --- a/src/components/ProxyDialog.vue +++ b/src/components/ProxyDialog.vue @@ -231,8 +231,11 @@ export default { */ cleanupModal() { if (this.modal) { - this.modal.hide(); - this.modal.dispose(); + try { + this.modal.hide(); + } catch (e) { + console.warn("Modal hide failed:", e); + } } document.body.classList.remove('modal-open'); document.body.style.paddingRight = ''; diff --git a/src/components/TagsManager.vue b/src/components/TagsManager.vue index 19c8e481b..398cd8bd7 100644 --- a/src/components/TagsManager.vue +++ b/src/components/TagsManager.vue @@ -248,6 +248,20 @@ export default { this.modal = new Modal(this.$refs.modal); this.getExistingTags(); }, + beforeRouteLeave(to, from, next) { + this.cleanupModal(); + next(); + }, + + watch: { + $route(to, from) { + this.cleanupModal(); + } + }, + + beforeUnmount() { + this.cleanupModal(); + }, methods: { /** * Show the add tag dialog @@ -459,6 +473,22 @@ export default { this.newTags = []; this.deleteTags = []; this.processing = false; + }, + /** + * Clean up modal and restore scroll behavior + * @returns {void} + */ + cleanupModal() { + if (this.modal) { + try { + this.modal.hide(); + } catch (e) { + console.warn("Modal hide failed:", e); + } + } + document.body.classList.remove('modal-open'); + document.body.style.paddingRight = ''; + document.body.style.overflow = ''; } }, };