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

Allow tabbing through the media manager grid #38141

Merged
merged 1 commit into from
Jun 27, 2022
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 @@ -3,15 +3,18 @@
class="media-browser-select"
:aria-label="translate('COM_MEDIA_TOGGLE_SELECT_ITEM')"
:title="translate('COM_MEDIA_TOGGLE_SELECT_ITEM')"
tabindex="0"
@focusin="focused(true)"
@focusout="focused(false)"
/>
<div
class="media-browser-actions"
:class="{ active: showActions }"
>
<media-browser-action-item-toggle
ref="actionToggle"
:on-focused="focused"
:main-action="openActions"
@on-focused="focused"
@keyup.up="openLastActions()"
@keyup.down="openActions()"
/>
Expand All @@ -29,6 +32,7 @@
:closing-action="hideActions"
@keyup.up="$refs.actionDelete.$el.focus()"
@keyup.down="$refs.actionDelete.$el.previousElementSibling.focus()"
@keyup.esc="hideActions"
/>
</li>
<li>
Expand All @@ -40,6 +44,7 @@
:closing-action="hideActions"
@keyup.up="$refs.actionPreview.$el.focus()"
@keyup.down="$refs.actionPreview.$el.previousElementSibling.focus()"
@keyup.esc="hideActions"
/>
</li>
<li>
Expand All @@ -61,6 +66,7 @@
? $refs.actionShare.$el.focus()
: $refs.actionShare.$el.previousElementSibling.focus()
"
@keyup.esc="hideActions"
/>
</li>
<li>
Expand All @@ -72,6 +78,7 @@
:closing-action="hideActions"
@keyup.up="$refs.actionRename.$el.focus()"
@keyup.down="$refs.actionRename.$el.previousElementSibling.focus()"
@keyup.esc="hideActions"
/>
</li>
<li>
Expand All @@ -87,6 +94,7 @@
: $refs.actionEdit.$el.previousElementSibling.focus()
"
@keyup.down="$refs.actionDelete.$el.focus()"
@keyup.esc="hideActions"
/>
</li>
<li>
Expand All @@ -106,6 +114,7 @@
? $refs.actionPreview.$el.focus()
: $refs.actionPreview.$el.previousElementSibling.focus()
"
@keyup.esc="hideActions"
/>
</li>
</ul>
Expand All @@ -121,12 +130,12 @@ export default {
name: 'MediaBrowserActionItemsContainer',
props: {
item: { type: Object, default: () => {} },
onFocused: { type: Function, default: () => {} },
edit: { type: Function, default: () => {} },
previewable: { type: Boolean, default: false },
downloadable: { type: Boolean, default: false },
shareable: { type: Boolean, default: false },
},
emits: ['toggle-settings'],
data() {
return {
showActions: false,
Expand Down Expand Up @@ -207,6 +216,9 @@ export default {
editItem() {
this.edit();
},
focused(bool) {
this.$emit('toggle-settings', bool);
},
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<button
type="button"
class="action-toggle"
tabindex="0"
:aria-label="translate('COM_MEDIA_OPEN_ITEM_ACTIONS')"
:title="translate('COM_MEDIA_OPEN_ITEM_ACTIONS')"
@keyup.enter="openActions()"
Expand All @@ -22,14 +23,14 @@ export default {
name: 'MediaBrowserActionItemToggle',
props: {
mainAction: { type: Function, default: () => {} },
onFocused: { type: Function, default: () => {} },
},
emits: ['on-focused'],
methods: {
openActions() {
this.mainAction();
},
focused(bool) {
this.onFocused(bool);
this.$emit('on-focused', bool);
},
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<template>
<div
class="media-browser-audio"
tabindex="0"
@dblclick="openPreview()"
@mouseleave="hideActions()"
@keyup.enter="openPreview()"
>
<div class="media-browser-item-preview">
<div class="file-background">
Expand All @@ -16,11 +18,11 @@
</div>
<media-browser-action-items-container
ref="container"
:focused="focused"
:item="item"
:previewable="true"
:downloadable="true"
:shareable="true"
@toggle-settings="toggleSettings"
/>
</div>
</template>
Expand All @@ -30,6 +32,7 @@ export default {
name: 'MediaBrowserItemAudio',
// eslint-disable-next-line vue/require-prop-types
props: ['item', 'focused'],
emits: ['toggle-settings'],
data() {
return {
showActions: false,
Expand All @@ -44,6 +47,9 @@ export default {
openPreview() {
this.$refs.container.openPreview();
},
toggleSettings(bool) {
this.$emit('toggle-settings', bool);
},
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
>
<div
class="media-browser-item-preview"
tabindex="0"
@dblclick.stop.prevent="onPreviewDblClick()"
@keyup.enter="onPreviewDblClick()"
>
<div class="file-background">
<div class="folder-icon">
Expand All @@ -18,8 +20,8 @@
</div>
<media-browser-action-items-container
ref="container"
:focused="focused"
:item="item"
@toggle-settings="toggleSettings"
/>
</div>
</template>
Expand All @@ -30,7 +32,8 @@ export default {
name: 'MediaBrowserItemDirectory',
mixins: [navigable],
// eslint-disable-next-line vue/require-prop-types
props: ['item', 'focused'],
props: ['item'],
emits: ['toggle-settings'],
data() {
return {
showActions: false,
Expand All @@ -45,6 +48,9 @@ export default {
hideActions() {
this.$refs.container.hideActions();
},
toggleSettings(bool) {
this.$emit('toggle-settings', bool);
},
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
/>
<media-browser-action-items-container
ref="container"
:focused="focused"
:item="item"
:previewable="true"
:downloadable="true"
:shareable="true"
@toggle-settings="toggleSettings"
/>
</div>
</template>
Expand All @@ -35,6 +35,7 @@ export default {
name: 'MediaBrowserItemDocument',
// eslint-disable-next-line vue/require-prop-types
props: ['item', 'focused'],
emits: ['toggle-settings'],
data() {
return {
showActions: false,
Expand All @@ -49,6 +50,9 @@ export default {
openPreview() {
this.$refs.container.openPreview();
},
toggleSettings(bool) {
this.$emit('toggle-settings', bool);
},
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
/>
<media-browser-action-items-container
ref="container"
:focused="focused"
:item="item"
:previewable="true"
:downloadable="true"
:shareable="true"
@toggle-settings="toggleSettings"
/>
</div>
</template>
Expand All @@ -34,6 +34,7 @@ export default {
name: 'MediaBrowserItemFile',
// eslint-disable-next-line vue/require-prop-types
props: ['item', 'focused'],
emits: ['toggle-settings'],
data() {
return {
showActions: false,
Expand All @@ -48,6 +49,9 @@ export default {
openPreview() {
this.$refs.container.openPreview();
},
toggleSettings(bool) {
this.$emit('toggle-settings', bool);
},
},
};
</script>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<template>
<div
class="media-browser-image"
tabindex="0"
@dblclick="openPreview()"
@mouseleave="hideActions()"
@keyup.enter="openPreview()"
>
<div
class="media-browser-item-preview"
Expand Down Expand Up @@ -34,12 +36,12 @@
/>
<media-browser-action-items-container
ref="container"
:focused="focused"
:item="item"
:edit="editItem"
:previewable="true"
:downloadable="true"
:shareable="true"
@toggle-settings="toggleSettings"
/>
</div>
</template>
Expand All @@ -53,6 +55,7 @@ export default {
item: { type: Object, required: true },
focused: { type: Boolean, required: true, default: false },
},
emits: ['toggle-settings'],
data() {
return {
showActions: { type: Boolean, default: false },
Expand Down Expand Up @@ -98,6 +101,9 @@ export default {

window.location.href = fileBaseUrl + this.item.path;
},
toggleSettings(bool) {
this.$emit('toggle-settings', bool);
},
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ export default {

/**
* Handle the when an element is focused in the child to display the layover for a11y
* @param value
* @param active
*/
focused(value) {
toggleSettings(active) {
// eslint-disable-next-line no-unused-expressions
value ? this.mouseover() : this.mouseleave();
active ? this.mouseover() : this.mouseleave();
},
},
render() {
Expand All @@ -181,12 +181,11 @@ export default {
onClick: this.handleClick,
onMouseover: this.mouseover,
onMouseleave: this.mouseleave,
onFocused: this.focused,
},
[
h(this.itemType(), {
item: this.item,
focused: this.focused,
onToggleSettings: this.toggleSettings,
}),
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
</div>
<media-browser-action-items-container
ref="container"
:focused="focused"
:item="item"
:previewable="true"
:downloadable="true"
:shareable="true"
@toggle-settings="toggleSettings"
/>
</div>
</template>
Expand All @@ -30,6 +30,7 @@ export default {
name: 'MediaBrowserItemVideo',
// eslint-disable-next-line vue/require-prop-types
props: ['item', 'focused'],
emits: ['toggle-settings'],
data() {
return {
showActions: false,
Expand All @@ -44,6 +45,9 @@ export default {
openPreview() {
this.$refs.container.openPreview();
},
toggleSettings(bool) {
this.$emit('toggle-settings', bool);
},
},
};
</script>