Skip to content

Commit

Permalink
Add focus management for uploads
Browse files Browse the repository at this point in the history
Regarding: progressbar, to listwrapper on complete
  • Loading branch information
marcus-herrmann committed Nov 25, 2019
1 parent d0eef89 commit ad49132
Show file tree
Hide file tree
Showing 6 changed files with 910 additions and 655 deletions.
2 changes: 1 addition & 1 deletion apps/files/src/components/FileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<oc-nav-item icon="file_upload" @click="triggerUpload">
<span id="files-file-upload-button" v-translate>Upload File</span>
<div slot="outer-content">
<input id="fileUploadInput" type="file" name="file" @change="$_ocUpload_addFileToQue" multiple ref="input" />
<input id="fileUploadInput" type="file" aria-labelledby="files-file-upload-button" name="file" @change="$_ocUpload_addFileToQue" multiple ref="input" />
</div>
</oc-nav-item>
</template>
Expand Down
17 changes: 13 additions & 4 deletions apps/files/src/components/FilesApp.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<div id="files" class="uk-flex uk-flex-column">
<files-app-bar />
<upload-progress v-show="inProgress.length" class="uk-padding-small uk-background-muted" />
<files-app-bar @upload-start="onUploadStart" @upload-end="onUploadEnd" />
<upload-progress v-show="inProgress.length" class="uk-padding-small uk-background-muted" :progressbarFocus="progressbarFocussed" />
<oc-grid class="uk-height-1-1 uk-flex-1 uk-overflow-auto">
<div class="uk-width-expand uk-overflow-auto uk-height-1-1" @dragover="$_ocApp_dragOver" :class="{ 'uk-visible@m' : _sidebarOpen }">
<div ref="filesListWrapper" tabindex="-1" class="uk-width-expand uk-overflow-auto uk-height-1-1" @dragover="$_ocApp_dragOver" :class="{ 'uk-visible@m' : _sidebarOpen }">
<oc-loader id="files-list-progress" v-if="loadingFolder"></oc-loader>
<trash-bin v-if="$route.name === 'files-trashbin'" :fileData="activeFiles" />
<shared-files-list v-else-if="sharedList" :fileData="activeFiles" @sideBarOpen="openSideBar" />
Expand Down Expand Up @@ -66,7 +66,8 @@ export default {
selected: [],
breadcrumbs: [],
self: {},
renameDialogErrorMessage: null
renameDialogErrorMessage: null,
progressbarFocussed: false
}
},
methods: {
Expand All @@ -77,6 +78,14 @@ export default {
console.info('trace', arguments)
},
onUploadStart () {
this.progressbarFocussed = true
},
onUploadEnd () {
this.progressbarFocussed = false
this.$refs.filesListWrapper.focus()
},
openFileActionBar (file) {
this.openFile({
filePath: file.path
Expand Down
10 changes: 8 additions & 2 deletions apps/files/src/components/FilesAppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<oc-button v-else disabled id="new-file-menu-btn" :uk-tooltip="_cannotCreateDialogText"><translate>+ New</translate></oc-button>
<oc-drop toggle="#new-file-menu-btn" mode="click">
<oc-nav>
<file-upload :path='currentPath' :headers="headers" @success="onFileSuccess" @error="onFileError" @progress="onFileProgress"></file-upload>
<folder-upload v-if="!isIE11()" :rootPath='item' :path='currentPath' :headers="headers" @success="onFileSuccess" @error="onFileError" @progress="onFileProgress"></folder-upload>
<file-upload :path='currentPath' :headers="headers" @success="onFileSuccess" @error="onFileError" @progress="onFileProgress" @upload-start="onUploadStart" @upload-end="onUploadEnd"></file-upload>
<folder-upload v-if="!isIE11()" :rootPath='item' :path='currentPath' :headers="headers" @success="onFileSuccess" @error="onFileError" @progress="onFileProgress" @upload-start="onUploadStart" @upload-end="onUploadEnd"></folder-upload>
<oc-nav-item @click="showCreateFolderDialog" id="new-folder-btn" icon="create_new_folder"><translate>Create new folder…</translate></oc-nav-item>
<oc-nav-item v-for="(newFileHandler, key) in newFileHandlers"
:key="key"
Expand Down Expand Up @@ -298,6 +298,12 @@ export default {
this.isLoadingSearch = false
})
},
onUploadStart () {
this.$emit('upload-start')
},
onUploadEnd () {
this.$emit('upload-end')
},
focusMobileSearchInput () {
this.$refs.mobileSearch.$el.querySelector('input').focus()
// nested vuetify VList animation will block native autofocus, so we use this workaround...
Expand Down
50 changes: 41 additions & 9 deletions apps/files/src/components/UploadProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,30 @@
id="files-upload-progress-dropdown-trigger"
icon="expand_more"
/>
<translate
:translate-n="count"
translate-plural="Uploading %{ count } items"
>
Uploading %{ count } item
</translate>
<span id="upload-label">
<translate
:translate-n="count"
translate-plural="Uploading %{ count } items"
>
Uploading %{ count } item
</translate>
</span>
<oc-grid
gutter="small"
flex
class="uk-width-1-1 uk-width-medium@s"
>
<oc-progress
ref="progressbar"
:value="totalUploadProgress"
:max="100"
aria-labelledby="upload-label"
class="uk-width-expand uk-margin-remove-bottom"
/>
<span>
{{ totalUploadProgress | roundNumber}} %
</span>
<oc-hidden-announcer level="assertive" :announcement="announcement" />
</oc-grid>
</oc-grid>
<oc-drop
Expand All @@ -47,15 +52,30 @@ import Mixins from '../mixins'
export default {
name: 'UploadProgress',
data () {
return {
announcement: '',
announcementOnComplete: this.$gettext('Upload complete')
}
},
props: {
progressbarFocus: {
type: Boolean,
default: false,
required: true
}
},
components: {
UploadMenu
},
mixins: [
Mixins
],
methods: {
focusProgressbar () {
this.$refs.progressbar.$el.focus()
}
},
computed: {
...mapGetters('Files', ['inProgress', 'uploaded']),
Expand All @@ -82,6 +102,18 @@ export default {
return progressTotal
}
},
watch: {
progressbarFocus (value) {
if (value) {
this.focusProgressbar()
}
},
totalUploadProgress (value) {
if (value === 100) {
this.announcement = this.announcementOnComplete
}
}
}
}
</script>
2 changes: 2 additions & 0 deletions apps/files/src/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export default {
},

$_ocUpload (file, path, overwrite = null, emitSuccess = true, addToProgress = true) {
this.$emit('upload-start')
let basePath = this.path || ''
let relativePath = path
if (addToProgress) {
Expand Down Expand Up @@ -302,6 +303,7 @@ export default {
}

promise.then(e => {
this.$emit('upload-end')
this.removeFileFromProgress(file)
if (emitSuccess) {
this.$emit('success', e, file)
Expand Down
Loading

0 comments on commit ad49132

Please sign in to comment.