Skip to content

Commit 32264c7

Browse files
authored
Merge pull request #55737 from nextcloud/backport/55666/stable31
2 parents 27f4f2d + d6c7b75 commit 32264c7

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

apps/files/src/composables/useFilenameFilter.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,29 @@ import { watchThrottled } from '@vueuse/core'
88
import { onMounted, onUnmounted, ref } from 'vue'
99
import { FilenameFilter } from '../filters/FilenameFilter'
1010

11+
const searchQuery = ref('')
12+
13+
/**
14+
* This is for the non-component usage to modify the query
15+
*/
16+
export function useSearchQuery() {
17+
/**
18+
* Updating the search query ref
19+
* @param value The new value
20+
*/
21+
function updateQuery(value: string) {
22+
searchQuery.value = value
23+
}
24+
25+
return {
26+
updateQuery,
27+
}
28+
}
29+
1130
/**
1231
* This is for the `Navigation` component to provide a filename filter
1332
*/
1433
export function useFilenameFilter() {
15-
const searchQuery = ref('')
1634
const filenameFilter = new FilenameFilter()
1735

1836
/**

apps/files/src/router/router.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Router, { isNavigationFailure, NavigationFailureType } from 'vue-router'
1111
import Vue from 'vue'
1212

1313
import { useFilesStore } from '../store/files'
14+
import { useSearchQuery } from '../composables/useFilenameFilter'
1415
import { useNavigation } from '../composables/useNavigation'
1516
import { usePathsStore } from '../store/paths'
1617
import logger from '../logger'
@@ -87,6 +88,12 @@ router.beforeEach((to, from, next) => {
8788
const fromDir = (from.query?.dir || '/') as string
8889
const toDir = (to.query?.dir || '/') as string
8990

91+
if (fromDir !== toDir) {
92+
// we navigate to another directory -> unset the query
93+
const { updateQuery } = useSearchQuery()
94+
updateQuery('')
95+
}
96+
9097
// We are going back to a parent directory
9198
if (relative(fromDir, toDir) === '..') {
9299
const { currentView } = useNavigation()

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)