Skip to content

Commit 743ae04

Browse files
committed
Add accessability buttons to the file rows
1 parent ce911f8 commit 743ae04

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

resources/assets/scripts/components/server/components/filemanager/FileRow.vue

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
<template>
22
<div>
33
<div v-on:contextmenu="showContextMenu">
4-
<div class="row" :class="{ clickable: canEdit(file), 'active-selection': contextMenuVisible }" v-if="!file.directory">
4+
<div class="row" :class="{ 'cursor-pointer': canEdit(file), 'active-selection': contextMenuVisible }" v-if="!file.directory">
55
<div class="flex-none icon">
66
<Icon name="file-text" v-if="!file.symlink"/>
77
<Icon name="link2" v-else/>
88
</div>
99
<div class="flex-1">{{file.name}}</div>
1010
<div class="flex-1 text-right text-neutral-600">{{readableSize(file.size)}}</div>
1111
<div class="flex-1 text-right text-neutral-600">{{formatDate(file.modified)}}</div>
12-
<div class="flex-none w-1/6"></div>
12+
<div class="flex-none icon cursor-pointer" v-on:click="showContextMenu" ref="menuTriggerIcon">
13+
<Icon name="more-vertical" class="text-neutral-500"/>
14+
</div>
1315
</div>
14-
<router-link class="row clickable"
16+
<router-link class="row"
1517
:class="{ 'active-selection': contextMenuVisible }"
1618
:to="{ name: 'server-files', params: { path: getClickablePath(file.name) }}"
1719
v-else
@@ -22,9 +24,10 @@
2224
<div class="flex-1">{{file.name}}</div>
2325
<div class="flex-1 text-right text-neutral-600"></div>
2426
<div class="flex-1 text-right text-neutral-600">{{formatDate(file.modified)}}</div>
25-
<div class="flex-none w-1/6"></div>
27+
<div class="flex-none icon" v-on:click="showContextMenu" ref="menuTriggerIcon">
28+
<Icon name="more-vertical" class="text-neutral-500"/>
29+
</div>
2630
</router-link>
27-
2831
</div>
2932
<FileContextMenu
3033
class="context-menu"
@@ -129,13 +132,14 @@
129132
130133
// @ts-ignore
131134
this.$parent.$emit('collapse-menus', this._uid);
132-
133135
this.contextMenuVisible = true;
134136
135-
const menuWidth = (this.$refs.contextMenu as VueType).$el.clientWidth;
136-
const positionElement = e.clientX - Math.round(menuWidth / 2);
137+
this.$nextTick(() => {
138+
const menuWidth = (this.$refs.contextMenu as VueType).$el.clientWidth;
139+
const positionElement = e.clientX - Math.round(menuWidth / 2);
137140
138-
(this.$refs.contextMenu as VueType).$el.setAttribute('style', `left: ${positionElement}; top: ${e.clientY}`);
141+
(this.$refs.contextMenu as VueType).$el.setAttribute('style', `left: ${positionElement}px; top: ${e.layerY}px`);
142+
});
139143
},
140144
141145
/**
@@ -153,6 +157,14 @@
153157
*/
154158
_clickListener: function (e: MouseEvent) {
155159
if (e.button !== 2 && this.contextMenuVisible) {
160+
// If we're clicking the trigger icon don't discard the event.
161+
if (this.$refs.menuTriggerIcon) {
162+
if (e.target === this.$refs.menuTriggerIcon || (this.$refs.menuTriggerIcon as HTMLDivElement).contains(e.target as Node)) {
163+
return;
164+
}
165+
}
166+
167+
// If the target is outside the scope of the context menu, hide it.
156168
if (e.target !== (this.$refs.contextMenu as VueType).$el && !(this.$refs.contextMenu as VueType).$el.contains(e.target as Node)) {
157169
this.contextMenuVisible = false;
158170
}

resources/assets/scripts/components/server/subpages/FileManager.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<div class="flex-1">Name</div>
3030
<div class="flex-1 text-right">Size</div>
3131
<div class="flex-1 text-right">Modified</div>
32-
<div class="flex-none w-1/6">Actions</div>
32+
<div class="flex-none"></div>
3333
</div>
3434
<div v-for="file in Array.concat(directories, files)">
3535
<FileRow

resources/assets/styles/components/filemanager.css

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,25 @@
22
& .header {
33
@apply .flex .text-xs .text-neutral-600 .pb-4 .font-bold .border-b .border-neutral-200 .mb-3 .uppercase;
44

5-
& > div {
5+
& > div:not(:last-of-type) {
66
@apply .pr-4;
77
}
88
}
99

1010
& .row {
11-
@apply .flex .text-sm .py-3 .text-sm .border .border-transparent .text-black .rounded;
11+
@apply .flex .text-sm .py-3 .text-sm .border .border-transparent .text-black .rounded .no-underline;
1212

13-
& > div {
13+
& > div:not(:last-of-type) {
1414
@apply .pr-4;
1515
}
1616

17-
&.clickable {
18-
@apply .no-underline .cursor-pointer;
19-
}
20-
21-
&.active-selection, &.clickable:hover {
17+
&.active-selection, &:hover {
2218
@apply .bg-neutral-50 .text-neutral-900;
2319
}
2420

2521
& > .icon {
2622
@apply .w-8 .text-center;
23+
2724
& > svg {
2825
@apply .h-4;
2926
}

0 commit comments

Comments
 (0)