Skip to content

Commit ce67cec

Browse files
committed
fix: folder tree selection after any action in main content
Signed-off-by: mykh-hailo <kristianderonta0205@gmail.com>
1 parent 8f9b11e commit ce67cec

5 files changed

Lines changed: 26 additions & 4 deletions

File tree

apps/files/src/components/FilesNavigationList.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import NcAppNavigationList from '@nextcloud/vue/components/NcAppNavigationList'
1212
import FilesNavigationListItem from './FilesNavigationListItem.vue'
1313
import { useVisibleViews } from '../composables/useViews.ts'
1414
15+
defineProps<{
16+
activeViewId?: string
17+
}>()
18+
1519
const views = useVisibleViews()
1620
const rootViews = computed(() => views.value
1721
.filter((view) => !view.parent)
@@ -47,6 +51,7 @@ function sortViews(a: IView, b: IView): number {
4751
<FilesNavigationListItem
4852
v-for="view in rootViews"
4953
:key="view.id"
54+
:active-view-id="activeViewId"
5055
:view="view" />
5156
</NcAppNavigationList>
5257
</template>

apps/files/src/components/FilesNavigationListItem.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { folderTreeId } from '../services/FolderTree.ts'
1515
import { useViewConfigStore } from '../store/viewConfig.ts'
1616
1717
const props = withDefaults(defineProps<{
18+
activeViewId?: string
1819
view: IView
1920
level?: number
2021
}>(), {
@@ -62,6 +63,7 @@ const sortedChildViews = computed(() => childViews.value.slice().sort((a, b) =>
6263
return collator.compare(a.name, b.name)
6364
}))
6465
const hasChildViews = computed(() => childViews.value.length > 0)
66+
const isActiveView = computed(() => props.activeViewId === props.view.id)
6567
6668
const navigationRoute = computed(() => {
6769
if (props.view.params) {
@@ -138,6 +140,7 @@ export default {
138140
<template>
139141
<NcAppNavigationItem
140142
class="files-navigation__item"
143+
:active="isActiveView"
141144
allow-collapse
142145
:loading="isLoading"
143146
:data-cy-files-navigation-item="view.id"
@@ -161,6 +164,7 @@ export default {
161164
<FilesNavigationListItem
162165
v-for="childView in sortedChildViews"
163166
:key="childView.id"
167+
:active-view-id="activeViewId"
164168
:level="level + 1"
165169
:view="childView" />
166170
</NcAppNavigationItem>

apps/files/src/views/FilesNavigation.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<FilesNavigationSearch />
1212
</template>
1313
<template #default>
14-
<FilesNavigationList />
14+
<FilesNavigationList :active-view-id="currentNavigationView" />
1515

1616
<!-- Settings modal-->
1717
<FilesAppSettings
@@ -42,6 +42,7 @@
4242
import { emit } from '@nextcloud/event-bus'
4343
import { getNavigation } from '@nextcloud/files'
4444
import { t } from '@nextcloud/l10n'
45+
import { isSamePath } from '@nextcloud/paths'
4546
import { computed, ref, watchEffect } from 'vue'
4647
import { useRoute } from 'vue-router/composables'
4748
import NcAppNavigation from '@nextcloud/vue/components/NcAppNavigation'
@@ -65,6 +66,18 @@ const allViews = useViews()
6566
6667
const route = useRoute()
6768
const currentViewId = computed(() => route?.params?.view || 'files')
69+
const currentNavigationView = computed(() => {
70+
const routeDir = typeof route.query?.dir === 'string' ? route.query.dir : undefined
71+
if (routeDir) {
72+
const matchingView = allViews.value.find((view) => typeof view.params?.dir === 'string' && isSamePath(view.params.dir, routeDir))
73+
if (matchingView) {
74+
return matchingView.id
75+
}
76+
return undefined
77+
}
78+
79+
return route?.params?.view || 'files'
80+
})
6881
watchEffect(() => {
6982
if (currentViewId.value !== activeStore.activeView?.id) {
7083
logger.debug(`Route view id ${currentViewId.value} is different from active view id ${activeStore.activeView?.id}, updating active view...`)

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)