Skip to content

Commit d778f07

Browse files
fix(files): update loading indicator behavior during folder navigation
Signed-off-by: Luka Trovic <luka@nextcloud.com>
1 parent df1224e commit d778f07

3 files changed

Lines changed: 13 additions & 52 deletions

File tree

apps/files/src/components/VirtualList.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
<template>
66
<div
77
class="files-list"
8-
:class="{ 'files-list--grid': gridMode }"
8+
:class="{
9+
'files-list--grid': gridMode,
10+
'files-list--loading': loading,
11+
}"
912
data-cy-files-list
1013
@scroll.passive="onScroll">
1114
<!-- Header -->
@@ -18,13 +21,12 @@
1821
</div>
1922

2023
<div
21-
v-if="dataSources.length === 0 || loading"
24+
v-if="dataSources.length === 0"
2225
class="files-list__empty">
2326
<slot name="empty" />
2427
</div>
2528

2629
<table
27-
v-if="!loading"
2830
:aria-hidden="dataSources.length === 0"
2931
:inert="dataSources.length === 0"
3032
class="files-list__table"
@@ -447,3 +449,10 @@ export default defineComponent({
447449
},
448450
})
449451
</script>
452+
453+
<style scoped>
454+
.files-list--loading {
455+
opacity: 0.3;
456+
}
457+
</style>
458+

apps/files/src/views/FilesList.vue

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
<FilesListVirtual
9191
v-else
9292
ref="filesListVirtual"
93-
:loading="loading && !isRefreshing"
93+
:loading="loading"
9494
:current-folder="currentFolder"
9595
:current-view="currentView"
9696
:nodes="dirContentsSorted"
@@ -99,7 +99,6 @@
9999
<!-- Initial loading -->
100100
<NcLoadingIcon
101101
v-if="loading && !isRefreshing"
102-
data-cy-files-loading
103102
class="files-list__loading-icon"
104103
:size="38"
105104
:name="t('files', 'Loading current folder')" />
@@ -313,7 +312,6 @@ export default defineComponent({
313312
314313
loading: true,
315314
loadingAction: null as string | null,
316-
changingLocation: false,
317315
error: null as string | null,
318316
controller: new AbortController(),
319317
promise: null as Promise<ContentsWithRoot> | null,
@@ -413,7 +411,6 @@ export default defineComponent({
413411
return this.currentFolder !== undefined
414412
&& !this.isEmptyDir
415413
&& this.loading
416-
&& !this.changingLocation
417414
},
418415
419416
/**
@@ -480,14 +477,12 @@ export default defineComponent({
480477
}
481478
482479
logger.debug('View changed', { newView, oldView })
483-
this.changingLocation = true
484480
this.selectionStore.reset()
485481
this.fetchContent()
486482
},
487483
488484
directory(newDir, oldDir) {
489485
logger.debug('Directory changed', { newDir, oldDir })
490-
this.changingLocation = true
491486
// TODO: preserve selection on browsing?
492487
this.selectionStore.reset()
493488
this.sidebar.close()
@@ -614,7 +609,6 @@ export default defineComponent({
614609
this.error = humanizeWebDAVError(error)
615610
} finally {
616611
this.loading = false
617-
this.changingLocation = false
618612
}
619613
},
620614

tests/playwright/e2e/files/files-navigation.spec.ts

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -48,46 +48,4 @@ test.describe('Files: Navigation', () => {
4848
await expect(filesListPage.getRowForFile('baz')).toBeVisible()
4949
await expect(filesListPage.getRowForFile('baz')).toBeActiveRow()
5050
})
51-
52-
test('show loading indicator when navigating', async ({ page, filesListPage }) => {
53-
await filesListPage.navigateToFolder('foo/bar/baz')
54-
await expect(page.locator('[data-cy-files-list-row-fileid]')).toHaveCount(0)
55-
56-
// Block the PROPFIND request to simulate a slow network and show the loading indicator
57-
let releaseNavigation!: () => void
58-
const navigationBlocked = new Promise<void>((resolve) => {
59-
releaseNavigation = resolve
60-
})
61-
let blockedNavigationRequest = false
62-
await page.route(/remote\.php\/dav\/files\//, async (route) => {
63-
const request = route.request()
64-
if (!blockedNavigationRequest && request.method() === 'PROPFIND' && request.url().includes('/foo/bar')) {
65-
blockedNavigationRequest = true
66-
await navigationBlocked
67-
}
68-
69-
await route.continue()
70-
})
71-
72-
// Navigate back to the parent folder — the PROPFIND request will be blocked
73-
const navigationResponse = page.waitForResponse((response) => response.url().includes('/remote.php/dav/files/')
74-
&& response.request().method() === 'PROPFIND'
75-
&& response.url().includes('/foo/bar'))
76-
77-
await page.goBack()
78-
79-
await expect.poll(() => new URL(page.url()).searchParams.get('dir')).toBe('/foo/bar')
80-
await expect(page.locator('[data-cy-files-loading]')).toBeVisible()
81-
expect(blockedNavigationRequest).toBe(true)
82-
83-
// Release the blocked navigation request and wait for it to complete
84-
releaseNavigation()
85-
await navigationResponse
86-
await page.unroute(/remote\.php\/dav\/files\//)
87-
88-
// Wait for the loading indicator to disappear and the folder to be rendered
89-
await expect(page.locator('[data-cy-files-loading]')).not.toBeVisible()
90-
await expect(filesListPage.getRowForFile('baz')).toBeVisible()
91-
await expect(filesListPage.getRowForFile('baz')).toBeActiveRow()
92-
})
9351
})

0 commit comments

Comments
 (0)