Fix click-outside for sidebar

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr
2022-11-03 18:19:23 +01:00
parent 8fc4238bd9
commit 7a23f3b0d2
2 changed files with 8 additions and 7 deletions

View File

@@ -23,7 +23,7 @@
<template> <template>
<NcContent app-name="deck" :class="{ 'nav-hidden': !navShown, 'sidebar-hidden': !sidebarRouterView }"> <NcContent app-name="deck" :class="{ 'nav-hidden': !navShown, 'sidebar-hidden': !sidebarRouterView }">
<AppNavigation /> <AppNavigation />
<NcAppContent @click="clickCloseSidebar()"> <NcAppContent>
<router-view /> <router-view />
</NcAppContent> </NcAppContent>
@@ -122,11 +122,6 @@ export default {
hideModal() { hideModal() {
this.$router.push({ name: 'board' }) this.$router.push({ name: 'board' })
}, },
clickCloseSidebar() {
if (this.sidebarShown) {
this.$router.push({ name: 'board' })
}
},
}, },
} }
</script> </script>

View File

@@ -21,7 +21,7 @@
--> -->
<template> <template>
<router-view v-if="visible" name="sidebar" /> <router-view v-if="visible" v-click-outside="onClickOutside" name="sidebar" />
</template> </template>
<script> <script>
@@ -37,6 +37,12 @@ export default {
closeSidebar() { closeSidebar() {
this.$router.push({ name: 'board' }) this.$router.push({ name: 'board' })
}, },
onClickOutside(e) {
if (Array.from(document.querySelectorAll('.card')).some(node => node.contains(e.target))) {
return
}
this.closeSidebar()
},
}, },
} }
</script> </script>