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

View File

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