Skip to content

Commit

Permalink
Close sidebar on route change
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Aug 22, 2022
1 parent be47eef commit 33870d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
10 changes: 9 additions & 1 deletion packages/web-app-files/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
</main>
</template>
<script lang="ts">
import { defineComponent } from '@vue/composition-api'
import { defineComponent, watch } from '@vue/composition-api'
import { Route } from 'vue-router'
import { useRoute, useStore } from 'web-pkg/src/composables'
import { bus } from 'web-pkg/src/instance'
export default defineComponent({
setup() {
const store = useStore<any>()
watch(useRoute(), (to: Route, from?: Route) => {
store.dispatch('Files/resetFileSelection')
})
},
data: () => ({
dragareaEnabled: false
}),
Expand Down
24 changes: 11 additions & 13 deletions packages/web-app-files/src/components/SideBar/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
:loading="loading"
:is-header-compact="isSingleResource"
v-bind="$attrs"
@beforeDestroy="focusSideBar"
@beforeDestroy="destroySideBar"
@mounted="focusSideBar"
@fileChanged="focusSideBar"
@selectPanel="setActiveSidebarPanel"
@close="closeSidebar"
@selectPanel="setActiveSideBarPanel"
@close="closeSideBar"
v-on="$listeners"
>
<template #header>
Expand Down Expand Up @@ -69,10 +69,10 @@ export default defineComponent({
const showSidebar = computed(() => !store.getters['Files/sidebar/closed'])
const sidebarActivePanel = computed(() => store.getters['Files/sidebar/activePanel'])
const closeSidebar = () => {
const closeSideBar = () => {
store.dispatch('Files/sidebar/close')
}
const setActiveSidebarPanel = (panelName) => {
const setActiveSideBarPanel = (panelName) => {
store.dispatch('Files/sidebar/setActivePanel', panelName)
}
Expand All @@ -84,20 +84,18 @@ export default defineComponent({
})
}
watch(useRoute(), (to: Route, from?: Route) => {
store.dispatch('Files/resetFileSelection')
if (from?.name !== to.name) {
closeSidebar()
}
})
const destroySideBar = (component, event) => {
focusSideBar(component, event)
closeSideBar()
}
return {
hasShareJail: useCapabilityShareJailEnabled(),
publicLinkPassword: usePublicLinkPassword({ store }),
showSidebar,
sidebarActivePanel,
closeSidebar,
setActiveSidebarPanel,
setActiveSideBarPanel,
destroySideBar,
focusSideBar
}
},
Expand Down

0 comments on commit 33870d1

Please sign in to comment.