Skip to content

Commit ee21204

Browse files
authored
Merge pull request #41577 from nextcloud/fix/41568/files-list--valid-table-layout
fix(files): make files list valid table layout
2 parents 688e635 + 346c617 commit ee21204

5 files changed

Lines changed: 59 additions & 41 deletions

File tree

apps/files/src/components/FileEntry/FileEntryActions.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export default Vue.extend({
251251
* sure there is one at the time we call it.
252252
*/
253253
getBoundariesElement() {
254-
return document.querySelector('.app-content > table.files-list')
254+
return document.querySelector('.app-content > .files-list')
255255
},
256256
},
257257

apps/files/src/components/FilesListVirtual.vue

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,9 @@
3939
filesListWidth,
4040
}"
4141
:scroll-to-index="scrollToIndex"
42+
:caption="caption"
4243
@scroll="onScroll">
43-
<!-- Accessibility description and headers -->
4444
<template #before>
45-
<!-- Accessibility description -->
46-
<caption class="hidden-visually">
47-
{{ currentView.caption || t('files', 'List of files and folders.') }}
48-
{{ t('files', 'This list is not fully rendered for performance reasons. The files will be rendered as you navigate through the list.') }}
49-
</caption>
50-
5145
<!-- Headers -->
5246
<FilesListHeader v-for="header in sortedHeaders"
5347
:key="header.id"
@@ -200,6 +194,13 @@ export default Vue.extend({
200194
canUpload() {
201195
return this.currentFolder && (this.currentFolder.permissions & Permission.CREATE) !== 0
202196
},
197+
198+
caption() {
199+
const defaultCaption = t('files', 'List of files and folders.')
200+
const viewCaption = this.currentView.caption || defaultCaption
201+
const virtualListNote = t('files', 'This list is not fully rendered for performance reasons. The files will be rendered as you navigate through the list.')
202+
return viewCaption + '\n' + virtualListNote
203+
},
203204
},
204205
205206
watch: {
@@ -304,12 +305,11 @@ export default Vue.extend({
304305
--clickable-area: 44px;
305306
--icon-preview-size: 32px;
306307
307-
display: block;
308308
overflow: auto;
309309
height: 100%;
310310
will-change: scroll-position;
311311
312-
&::v-deep {
312+
& :deep() {
313313
// Table head, body and footer
314314
tbody {
315315
will-change: padding;
@@ -336,6 +336,10 @@ export default Vue.extend({
336336
flex-direction: column;
337337
}
338338
339+
.files-list__table {
340+
display: block;
341+
}
342+
339343
.files-list__thead,
340344
.files-list__tfoot {
341345
display: flex;

apps/files/src/components/VirtualList.vue

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
11
<template>
2-
<table class="files-list" data-cy-files-list>
2+
<div class="files-list" data-cy-files-list>
33
<!-- Header -->
44
<div ref="before" class="files-list__before">
55
<slot name="before" />
66
</div>
77

8-
<!-- Header -->
9-
<thead ref="thead" class="files-list__thead" data-cy-files-list-thead>
10-
<slot name="header" />
11-
</thead>
12-
13-
<!-- Body -->
14-
<tbody :style="tbodyStyle"
15-
class="files-list__tbody"
16-
:class="gridMode ? 'files-list__tbody--grid' : 'files-list__tbody--list'"
17-
data-cy-files-list-tbody>
18-
<component :is="dataComponent"
19-
v-for="({key, item}, i) in renderedItems"
20-
:key="key"
21-
:source="item"
22-
:index="i"
23-
v-bind="extraProps" />
24-
</tbody>
25-
26-
<!-- Footer -->
27-
<tfoot v-show="isReady"
28-
class="files-list__tfoot"
29-
data-cy-files-list-tfoot>
30-
<slot name="footer" />
31-
</tfoot>
32-
</table>
8+
<table class="files-list__table">
9+
<!-- Accessibility table caption for screen readers -->
10+
<caption v-if="caption" class="hidden-visually">
11+
{{ caption }}
12+
</caption>
13+
14+
<!-- Header -->
15+
<thead ref="thead" class="files-list__thead" data-cy-files-list-thead>
16+
<slot name="header" />
17+
</thead>
18+
19+
<!-- Body -->
20+
<tbody :style="tbodyStyle"
21+
class="files-list__tbody"
22+
:class="gridMode ? 'files-list__tbody--grid' : 'files-list__tbody--list'"
23+
data-cy-files-list-tbody>
24+
<component :is="dataComponent"
25+
v-for="({key, item}, i) in renderedItems"
26+
:key="key"
27+
:source="item"
28+
:index="i"
29+
v-bind="extraProps" />
30+
</tbody>
31+
32+
<!-- Footer -->
33+
<tfoot v-show="isReady"
34+
class="files-list__tfoot"
35+
data-cy-files-list-tfoot>
36+
<slot name="footer" />
37+
</tfoot>
38+
</table>
39+
</div>
3340
</template>
3441

3542
<script lang="ts">
@@ -75,6 +82,13 @@ export default Vue.extend({
7582
type: Boolean,
7683
default: false,
7784
},
85+
/**
86+
* Visually hidden caption for the table accesibility
87+
*/
88+
caption: {
89+
type: String,
90+
default: '',
91+
},
7892
},
7993
8094
data() {
@@ -232,13 +246,13 @@ export default Vue.extend({
232246
233247
onScroll() {
234248
this._onScrollHandle ??= requestAnimationFrame(() => {
235-
this._onScrollHandle = null;
249+
this._onScrollHandle = null
236250
const topScroll = this.$el.scrollTop - this.beforeHeight
237251
const index = Math.floor(topScroll / this.itemHeight) * this.columnCount
238252
// Max 0 to prevent negative index
239253
this.index = Math.max(0, index)
240254
this.$emit('scroll')
241-
});
255+
})
242256
},
243257
},
244258
})

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)