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

[4.0] [a11y] [NO CACHE] Make media manager browse view work with keyboard navigation #23950

Merged
merged 3 commits into from
Feb 27, 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
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Api {
data: JSON.stringify(data),
headers: {'Content-Type': 'application/json'},
onSuccess: (response) => {
notifications.success('COM_MEDIA_UPDLOAD_SUCCESS');
notifications.success('COM_MEDIA_UPLOAD_SUCCESS');
resolve(this._normalizeItem(JSON.parse(response).data))
},
onError: (xhr) => {
Expand All @@ -138,7 +138,7 @@ class Api {
/**
* Rename an item
* @param path
* @param newName
* @param newPath
* @return {Promise.<T>}
*/
rename(path, newPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<script>
import * as types from "./../store/mutation-types";
import {notifications} from "./../app/Notifications";
import Api from "./../app/Api";

export default {
name: 'media-app',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<template>
<ol class="media-breadcrumb">
<li class="media-breadcrumb-item" v-for="crumb in crumbs">
<a @click.stop.prevent="onCrumbClick(crumb)">{{ crumb.name }}</a>
</li>
</ol>
<nav class="media-breadcrumb" role="navigation" :aria-label="translate('COM_MEDIA_BREADCRUMB_LABEL')">
<ol>
<li class="media-breadcrumb-item" v-for="(val,index) in crumbs">
<a href="#" @click.stop.prevent="onCrumbClick(val)" v-bind:aria-current="(index === Object.keys(crumbs).length - 1) ? 'page' : undefined">{{ val.name }}</a>
</li>
</ol>
</nav>
</template>

<script>
Expand Down Expand Up @@ -62,7 +64,7 @@
});

return driveObject;
}
},
},
}
</script>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="media-browser-item-directory" @mouseleave="showActions = false">
<div class="media-browser-item-directory" @mouseleave="hideActions()">
<div class="media-browser-item-preview"
@dblclick.stop.prevent="onPreviewDblClick()">
<div class="file-background">
Expand All @@ -13,24 +13,37 @@
</div>
<a href="#" class="media-browser-select"
@click.stop="toggleSelect()"
:aria-label="translate('COM_MEDIA_TOGGLE_SELECT_ITEM')">
:aria-label="translate('COM_MEDIA_TOGGLE_SELECT_ITEM')"
@focus="focused(true)" @blur="focused(false)">
</a>
<div class="media-browser-actions" :class="{'active': showActions}">
<a href="#" class="action-toggle"
:aria-label="translate('COM_MEDIA_OPEN_ITEM_ACTIONS')">
<button class="action-toggle" type="button" ref="actionToggle"
:aria-label="translate('COM_MEDIA_OPEN_ITEM_ACTIONS')" @keyup.enter="openActions()"
@focus="focused(true)" @blur="focused(false)" @keyup.space="openActions()"
@keyup.down="openActions()" @keyup.up="openLastActions()">
<span class="image-browser-action fa fa-ellipsis-h" aria-hidden="true"
@click.stop="showActions = true"></span>
</a>
<div class="media-browser-actions-list">
<a href="#" class="action-rename"
:aria-label="translate('COM_MEDIA_ACTIN_RENAME')">
<span class="image-browser-action fa fa-text-width" aria-hidden="true"
@click.stop="openRenameModal()"></span>
</a>
<a href="#" class="action-delete"
:aria-label="translate('COM_MEDIA_ACTION_DELETE')">
<span class="image-browser-action fa fa-trash" aria-hidden="true" @click.stop="openConfirmDeleteModal()"></span>
</a>
@click.stop="openActions()"></span>
</button>
<div v-if="showActions" class="media-browser-actions-list">
<ul>
<li>
<button type="button" class="action-rename" ref="actionRename" @keyup.enter="openRenameModal()"
:aria-label="translate('COM_MEDIA_ACTION_RENAME')" @keyup.space="openRenameModal()"
@focus="focused(true)" @blur="focused(false)" @keyup.esc="hideActions()"
@keyup.up="$refs.actionDelete.focus()" @keyup.down="$refs.actionDelete.focus()">
<span class="image-browser-action fa fa-text-width" aria-hidden="true"
@click.stop="openRenameModal()"></span>
</button>
</li>
<li>
<button type="button" class="action-delete" ref="actionDelete" @keyup.enter="openConfirmDeleteModal()"
:aria-label="translate('COM_MEDIA_ACTION_DELETE')" @keyup.space="openConfirmDeleteModal()"
@focus="focused(true)" @blur="focused(false)" @keyup.esc="hideActions()"
@keyup.up="$refs.actionRename.focus()" @keyup.down="$refs.actionRename.focus()">
<span class="image-browser-action fa fa-trash" aria-hidden="true" @click.stop="openConfirmDeleteModal()"></span>
</button>
</li>
</ul>
</div>
</div>
</div>
Expand All @@ -46,7 +59,7 @@
showActions: false,
}
},
props: ['item'],
props: ['item', 'focused'],
mixins: [navigable],
methods: {
/* Handle the on preview double click event */
Expand All @@ -68,6 +81,21 @@
toggleSelect() {
this.$store.dispatch('toggleBrowserItemSelect', this.item);
},
/* Open actions dropdown */
openActions() {
this.showActions = true;
this.$nextTick(() => this.$refs.actionRename.focus());
},
/* Open actions dropdown and focus on last element */
openLastActions() {
this.showActions = true;
this.$nextTick(() => this.$refs.actionDelete.focus());
},
/* Hide actions dropdown */
hideActions() {
this.showActions = false;
this.$nextTick(() => this.$refs.actionToggle.focus());
},
}
}
</script>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="media-browser-item-file" @mouseleave="showActions = false">
<div class="media-browser-item-file" @mouseleave="hideActions()">
<div class="media-browser-item-preview">
<div class="file-background">
<div class="file-icon">
Expand All @@ -12,33 +12,53 @@
</div>
<a href="#" class="media-browser-select"
@click.stop="toggleSelect()"
:aria-label="translate('COM_MEDIA_TOGGLE_SELECT_ITEM')">
:aria-label="translate('COM_MEDIA_TOGGLE_SELECT_ITEM')"
@focus="focused(true)" @blur="focused(false)">
</a>
<div class="media-browser-actions" :class="{'active': showActions}">
<a href="#" class="action-toggle"
:aria-label="translate('COM_MEDIA_OPEN_ITEM_ACTIONS')">
<button href="#" class="action-toggle" type="button" ref="actionToggle"
:aria-label="translate('COM_MEDIA_OPEN_ITEM_ACTIONS')" @keyup.enter="openActions()"
@focus="focused(true)" @blur="focused(false)" @keyup.space="openActions()"
@keyup.down="openActions()" @keyup.up="openLastActions()">
<span class="image-browser-action fa fa-ellipsis-h" aria-hidden="true"
@click.stop="showActions = true"></span>
</a>
<div class="media-browser-actions-list">
<a href="#" class="action-download"
:aria-label="translate('COM_MEDIA_ACTION_DOWNLOAD')">
<span class="image-browser-action fa fa-download" aria-hidden="true"
@click.stop="download()"></span>
</a>
<a href="#" class="action-rename"
:aria-label="translate('COM_MEDIA_ACTIN_RENAME')">
<span class="image-browser-action fa fa-text-width" aria-hidden="true"
@click.stop="openRenameModal()"></span>
</a>
<a href="#" class="action-url"
:aria-label="translate('COM_MEDIA_ACTION_SHARE')">
<span class="image-browser-action fa fa-link" aria-hidden="true" @click.stop="openShareUrlModal()"></span>
</a>
<a href="#" class="action-delete"
:aria-label="translate('COM_MEDIA_ACTION_DELETE')">
<span class="image-browser-action fa fa-trash" aria-hidden="true" @click.stop="openConfirmDeleteModal()"></span>
</a>
@click.stop="openActions()"></span>
</button>
<div v-if="showActions" class="media-browser-actions-list">
<ul>
<li>
<button type="button" class="action-download" ref="actionDownload" @keyup.enter="download()"
:aria-label="translate('COM_MEDIA_ACTION_DOWNLOAD')" @keyup.space="download()"
@keyup.up="$refs.actionDelete.focus()" @keyup.down="$refs.actionRename.focus()">
<span class="image-browser-action fa fa-download" aria-hidden="true"
@click.stop="download()"></span>
</button>
</li>
<li>
<button type="button" class="action-rename" ref="actionRename" @keyup.space="openRenameModal()"
:aria-label="translate('COM_MEDIA_ACTION_RENAME')" @keyup.enter="openRenameModal()"
@focus="focused(true)" @blur="focused(false)" @keyup.esc="hideActions()"
@keyup.up="$refs.actionDownload.focus()" @keyup.down="$refs.actionUrl.focus()">
<span class="image-browser-action fa fa-text-width" aria-hidden="true"
@click.stop="openRenameModal()"></span>
</button>
</li>
<li>
<button type="button" class="action-url" ref="actionUrl" @keyup.space="openShareUrlModal()"
:aria-label="translate('COM_MEDIA_ACTION_SHARE')" @keyup.enter="openShareUrlModal()"
@focus="focused(true)" @blur="focused(false)" @keyup.esc="hideActions()"
@keyup.up="$refs.actionRename.focus()" @keyup.down="$refs.actionDelete.focus()">
<span class="image-browser-action fa fa-link" aria-hidden="true" @click.stop="openShareUrlModal()"></span>
</button>
</li>
<li>
<button type="button" class="action-delete" ref="actionDelete" @keyup.space="openConfirmDeleteModal()"
:aria-label="translate('COM_MEDIA_ACTION_DELETE')" @keyup.enter="openConfirmDeleteModal()"
@focus="focused(true)" @blur="focused(false)" @keyup.esc="hideActions()"
@keyup.up="$refs.actionUrl.focus()" @keyup.down="$refs.actionDownload.focus()">
<span class="image-browser-action fa fa-trash" aria-hidden="true" @click.stop="openConfirmDeleteModal()"></span>
</button>
</li>
</ul>
</div>
</div>
</div>
Expand All @@ -54,7 +74,7 @@
showActions: false,
}
},
props: ['item'],
props: ['item', 'focused'],
methods: {
/* Preview an item */
download() {
Expand All @@ -80,6 +100,21 @@
this.$store.commit(types.SELECT_BROWSER_ITEM, this.item);
this.$store.commit(types.SHOW_SHARE_MODAL);
},
/* Open actions dropdown */
openActions() {
this.showActions = true;
this.$nextTick(() => this.$refs.actionDownload.focus());
},
/* Open actions dropdown and focus on last element */
openLastActions() {
this.showActions = true;
this.$nextTick(() => this.$refs.actionDelete.focus());
},
/* Hide actions dropdown */
hideActions() {
this.showActions = false;
this.$nextTick(() => this.$refs.actionToggle.focus());
},
}
}
</script>
Loading