Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add focus management for uploads #2542

Merged
merged 1 commit into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 6 additions & 2 deletions apps/files/src/components/FilesApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<files-app-bar />
<upload-progress v-show="inProgress.length" class="uk-padding-small uk-background-muted" />
<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 @@ -142,7 +142,11 @@ export default {
this.renameDialogErrorMessage = this.validateFileName(value)
}
},

created () {
this.$root.$on('upload-end', () => {
this.delayForScreenreader(() => this.$refs.filesListWrapper.focus())
})
},
computed: {
...mapGetters('Files', [
'selectedFiles', 'activeFiles', 'dropzone', 'loadingFolder', 'highlightedFile', 'currentFolder', 'inProgress',
Expand Down
27 changes: 24 additions & 3 deletions apps/files/src/components/UploadProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
icon="expand_more"
/>
<translate
id="upload-label"
:translate-n="count"
translate-plural="Uploading %{ count } items"
>
Expand All @@ -21,13 +22,16 @@
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 +51,25 @@ import Mixins from '../mixins'

export default {
name: 'UploadProgress',

data () {
return {
announcement: '',
announcementOnComplete: this.$gettext('Upload complete')
}
},
components: {
UploadMenu
},

mixins: [
Mixins
],

created () {
this.$root.$on('upload-start', () => {
this.$nextTick(() => {
this.delayForScreenreader(() => this.$refs.progressbar.$el.focus())
})
})
},
computed: {
...mapGetters('Files', ['inProgress', 'uploaded']),

Expand All @@ -82,6 +96,13 @@ export default {

return progressTotal
}
},
watch: {
totalUploadProgress (value) {
if (value === 100) {
this.announcement = this.announcementOnComplete
}
}
}
}
</script>
8 changes: 8 additions & 0 deletions apps/files/src/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export default {
formDateFromNow (date) {
return moment(date).locale(this.$language.current).fromNow()
},
delayForScreenreader (func, delay = 500) {
/*
* Delay for screen readers Virtual buffers
*/
setTimeout(() => func(), delay)
},
fileTypeIcon (file) {
if (file) {
if (file.type === 'folder') {
Expand Down Expand Up @@ -287,6 +293,7 @@ export default {
},

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

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