Fix scroll lock

when the modal is opened, its sets overflow hidden, remove this style so as to unfreeze it
This commit is contained in:
mohit-nagaraj 2024-10-08 07:33:18 +05:30
parent 1dceb96c7c
commit 45b6c8a91d
No known key found for this signature in database

View file

@ -131,24 +131,18 @@ export default {
}, },
beforeRouteLeave(to, from, next) { beforeRouteLeave(to, from, next) {
if (this.modal) { this.cleanupModal();
this.modal.hide();
}
next(); next();
}, },
watch: { watch: {
$route(to, from) { $route(to, from) {
if (this.modal) { this.cleanupModal();
this.modal.hide();
}
} }
}, },
beforeUnmount() { beforeUnmount() {
if (this.modal) { this.cleanupModal();
this.modal.dispose();
}
}, },
methods: { 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 = '';
}
}, },
}; };
</script> </script>