Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove modal when navigating back #5165

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/components/CreateGroupDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,27 @@
import { Modal } from "bootstrap";

export default {
beforeRouteLeave(to, from, next) {
mohit-nagaraj marked this conversation as resolved.
Show resolved Hide resolved
this.cleanupModal();
next();
},
props: {},
emits: [ "added" ],
data: () => ({
modal: null,
groupName: null,
}),
watch: {
$route(to, from) {
this.cleanupModal();
}
},
mohit-nagaraj marked this conversation as resolved.
Show resolved Hide resolved
mounted() {
this.modal = new Modal(this.$refs.modal);
},
beforeUnmount() {
this.cleanupModal();
},
methods: {
/**
* Show the confirm dialog
Expand All @@ -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 = "";
mohit-nagaraj marked this conversation as resolved.
Show resolved Hide resolved
}
},
};
</script>
27 changes: 27 additions & 0 deletions src/components/NotificationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export default {
components: {
Confirm,
},
beforeRouteLeave(to, from, next) {
this.cleanupModal();
next();
},
props: {},
emits: [ "added" ],
data() {
Expand Down Expand Up @@ -226,10 +230,16 @@ export default {
this.notification.name = this.getUniqueDefaultName(to);
}
},
$route(to, from) {
this.cleanupModal();
}
},
mounted() {
this.modal = new Modal(this.$refs.modal);
},
beforeUnmount() {
this.cleanupModal();
},
methods: {

/**
Expand Down Expand Up @@ -334,6 +344,23 @@ 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) {
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 = "";
}
},
};
Expand Down
31 changes: 29 additions & 2 deletions src/components/ProxyDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ export default {
components: {
Confirm,
},
beforeRouteLeave(to, from, next) {
this.cleanupModal();
next();
},
props: {},
emits: [ "added" ],
data() {
Expand All @@ -125,11 +129,17 @@ export default {
}
};
},

watch: {
$route(to, from) {
this.cleanupModal();
}
},
mounted() {
this.modal = new Modal(this.$refs.modal);
},

beforeUnmount() {
this.cleanupModal();
},
methods: {
/**
* Show dialog to confirm deletion
Expand Down Expand Up @@ -209,6 +219,23 @@ export default {
}
});
},

/**
* 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 = "";
}
},
};
</script>
Expand Down
28 changes: 28 additions & 0 deletions src/components/TagsManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export default {
Tag,
VueMultiselect,
},
beforeRouteLeave(to, from, next) {
this.cleanupModal();
next();
},
props: {
/**
* Array of tags to be pre-selected
Expand Down Expand Up @@ -244,10 +248,18 @@ export default {
};
},
},
watch: {
$route(to, from) {
this.cleanupModal();
}
},
mounted() {
this.modal = new Modal(this.$refs.modal);
this.getExistingTags();
},
beforeUnmount() {
this.cleanupModal();
},
methods: {
/**
* Show the add tag dialog
Expand Down Expand Up @@ -459,6 +471,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 = "";
}
},
};
Expand Down
Loading