Fix stuck no-scroll class on modal close

This commit is contained in:
Christian Cueni 2022-10-11 15:57:32 +02:00
parent d57c341d8c
commit 871c69c0a9
2 changed files with 13 additions and 3 deletions

View File

@ -62,7 +62,11 @@ const clickLink = (to: string) => {
<div class="mt-6 pb-6 border-b border-gray-500"> <div class="mt-6 pb-6 border-b border-gray-500">
<ul> <ul>
<li>Shop</li> <li>Shop</li>
<li class="mt-6">Mediathek</li> <li class="mt-6">
<button @click="clickLink(`/media/versicherungsvermittlerin-media`)">
Mediathek
</button>
</li>
</ul> </ul>
</div> </div>
<button <button

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
// inspiration https://vuejs.org/examples/#modal // inspiration https://vuejs.org/examples/#modal
import { onMounted, watch } from "vue"; import { onMounted, onUnmounted ,watch } from "vue";
const props = defineProps<{ const props = defineProps<{
show: boolean; show: boolean;
@ -20,11 +20,17 @@ onMounted(() => {
appElement = document.getElementById("app"); appElement = document.getElementById("app");
}); });
onUnmounted( () => removeNoScroll())
const closeModal = () => { const closeModal = () => {
removeNoScroll();
emits("closemodal");
};
const removeNoScroll = () => {
if (appElement) { if (appElement) {
appElement.classList.remove("no-scroll"); appElement.classList.remove("no-scroll");
} }
emits("closemodal");
}; };
</script> </script>