mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 02:22:44 +01:00
feat: enhance accessibility with aria-labels and tabindex adjustments across various components
This commit is contained in:
@@ -79,6 +79,7 @@ async function copyDownloadLink(rom: DetailedRom) {
|
||||
fileIDs: downloadStore.fileIDsToDownload,
|
||||
})
|
||||
"
|
||||
:aria-label="`Download ${rom.name}`"
|
||||
>
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
@@ -89,7 +90,11 @@ async function copyDownloadLink(rom: DetailedRom) {
|
||||
>
|
||||
<v-icon icon="mdi-download" size="large" />
|
||||
</v-btn>
|
||||
<v-btn class="flex-grow-1" @click="copyDownloadLink(rom)">
|
||||
<v-btn
|
||||
:aria-label="`Copy download link ${rom.name}`"
|
||||
class="flex-grow-1"
|
||||
@click="copyDownloadLink(rom)"
|
||||
>
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
@@ -108,6 +113,7 @@ async function copyDownloadLink(rom: DetailedRom) {
|
||||
params: { rom: rom?.id },
|
||||
})
|
||||
"
|
||||
:aria-label="`Play ${rom.name}`"
|
||||
>
|
||||
<v-icon :icon="playInfoIcon" />
|
||||
</v-btn>
|
||||
@@ -120,6 +126,7 @@ async function copyDownloadLink(rom: DetailedRom) {
|
||||
params: { rom: rom?.id },
|
||||
})
|
||||
"
|
||||
:aria-label="`Play ${rom.name}`"
|
||||
>
|
||||
<v-icon :icon="playInfoIcon" />
|
||||
</v-btn>
|
||||
@@ -127,6 +134,7 @@ async function copyDownloadLink(rom: DetailedRom) {
|
||||
v-if="is3DSRom"
|
||||
class="flex-grow-1"
|
||||
@click="emitter?.emit('showQRCodeDialog', rom)"
|
||||
:aria-label="`Show ${rom.name} QR code`"
|
||||
>
|
||||
<v-icon :icon="qrCodeIcon" />
|
||||
</v-btn>
|
||||
@@ -139,7 +147,11 @@ async function copyDownloadLink(rom: DetailedRom) {
|
||||
location="bottom"
|
||||
>
|
||||
<template #activator="{ props: menuProps }">
|
||||
<v-btn class="flex-grow-1" v-bind="menuProps">
|
||||
<v-btn
|
||||
:aria-label="`${rom.name} admin menu`"
|
||||
class="flex-grow-1"
|
||||
v-bind="menuProps"
|
||||
>
|
||||
<v-icon icon="mdi-dots-vertical" size="large" />
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
@@ -25,6 +25,7 @@ const { activeFirmwareDrawer } = storeToRefs(galleryViewStore);
|
||||
v-bind="props"
|
||||
icon="mdi-memory"
|
||||
:color="activeFirmwareDrawer ? 'primary' : ''"
|
||||
aria-label="Firmwares"
|
||||
@click="galleryViewStore.switchActiveFirmwareDrawer()"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -56,6 +56,7 @@ const aspectRatioOptions = computed(() => [
|
||||
source: t("platform.old-horizontal-cases"),
|
||||
},
|
||||
]);
|
||||
const tabIndex = computed(() => (activePlatformInfoDrawer.value ? 0 : -1));
|
||||
|
||||
const PLATFORM_INFO_FIELDS: {
|
||||
key: keyof Platform;
|
||||
@@ -208,6 +209,7 @@ watch(
|
||||
class="bg-toplayer"
|
||||
@click="showEditable"
|
||||
size="small"
|
||||
:tabindex="tabIndex"
|
||||
>
|
||||
<template #loader>
|
||||
<v-progress-circular
|
||||
@@ -220,13 +222,18 @@ watch(
|
||||
<v-icon>mdi-pencil</v-icon></v-btn
|
||||
>
|
||||
<template v-else>
|
||||
<v-btn @click="closeEditable" size="small" class="bg-toplayer"
|
||||
<v-btn
|
||||
@click="closeEditable"
|
||||
size="small"
|
||||
class="bg-toplayer"
|
||||
:tabindex="tabIndex"
|
||||
><v-icon color="romm-red">mdi-close</v-icon></v-btn
|
||||
>
|
||||
<v-btn
|
||||
@click="updatePlatform()"
|
||||
size="small"
|
||||
class="bg-toplayer ml-1"
|
||||
:tabindex="tabIndex"
|
||||
><v-icon color="romm-green">mdi-check</v-icon></v-btn
|
||||
>
|
||||
</template>
|
||||
@@ -256,11 +263,13 @@ watch(
|
||||
v-model="updatedPlatform.display_name"
|
||||
:readonly="!isEditable"
|
||||
@keyup.enter="updatePlatform()"
|
||||
:tabindex="tabIndex"
|
||||
/>
|
||||
</div>
|
||||
<div class="mt-6">
|
||||
<v-btn
|
||||
class="bg-toplayer my-1"
|
||||
:tabindex="tabIndex"
|
||||
@click="emitter?.emit('showUploadRomDialog', currentPlatform)"
|
||||
>
|
||||
<v-icon class="text-romm-green mr-2"
|
||||
@@ -273,6 +282,7 @@ watch(
|
||||
rounded="4"
|
||||
:loading="scanning"
|
||||
@click="scan"
|
||||
:tabindex="tabIndex"
|
||||
class="ml-2 my-1 bg-toplayer"
|
||||
>
|
||||
<template #prepend>
|
||||
@@ -307,8 +317,9 @@ watch(
|
||||
style="text-decoration: none; color: inherit"
|
||||
:href="`https://www.igdb.com/platforms/${currentPlatform.slug}`"
|
||||
target="_blank"
|
||||
:tabindex="tabIndex"
|
||||
>
|
||||
<v-chip class="pl-0 mt-1" size="small" @click.stop>
|
||||
<v-chip tabindex="-1" class="pl-0 mt-1" size="small" @click.stop>
|
||||
<v-avatar class="mr-2" size="30" rounded="0">
|
||||
<v-img src="/assets/scrappers/igdb.png" />
|
||||
</v-avatar>
|
||||
@@ -323,8 +334,9 @@ watch(
|
||||
:class="{
|
||||
'ml-1': currentPlatform.igdb_id || currentPlatform.moby_id,
|
||||
}"
|
||||
:tabindex="tabIndex"
|
||||
>
|
||||
<v-chip class="pl-0 mt-1" size="small" @click.stop>
|
||||
<v-chip tabindex="-1" class="pl-0 mt-1" size="small" @click.stop>
|
||||
<v-avatar class="mr-2" size="30" rounded="0">
|
||||
<v-img src="/assets/scrappers/ss.png" />
|
||||
</v-avatar>
|
||||
@@ -336,8 +348,9 @@ watch(
|
||||
style="text-decoration: none; color: inherit"
|
||||
target="_blank"
|
||||
:class="{ 'ml-1': currentPlatform.igdb_id }"
|
||||
:tabindex="tabIndex"
|
||||
>
|
||||
<v-chip class="pl-0 mt-1" size="small" @click.stop>
|
||||
<v-chip tabindex="-1" class="pl-0 mt-1" size="small" @click.stop>
|
||||
<v-avatar class="mr-2" size="30" rounded="0">
|
||||
<v-img src="/assets/scrappers/moby.png" />
|
||||
</v-avatar>
|
||||
@@ -354,8 +367,9 @@ watch(
|
||||
currentPlatform.ss_id ||
|
||||
currentPlatform.moby_id,
|
||||
}"
|
||||
:tabindex="tabIndex"
|
||||
>
|
||||
<v-chip class="pl-0 mt-1" size="small" @click.stop>
|
||||
<v-chip tabindex="-1" class="pl-0 mt-1" size="small" @click.stop>
|
||||
<v-avatar class="mr-2" size="25" rounded="1">
|
||||
<v-img src="/assets/scrappers/ra.png" />
|
||||
</v-avatar>
|
||||
@@ -368,7 +382,7 @@ watch(
|
||||
<v-card-text class="pa-4 d-flex flex-wrap ga-2">
|
||||
<template v-for="field in PLATFORM_INFO_FIELDS" :key="field.key">
|
||||
<div>
|
||||
<v-chip size="small" class="px-0" label>
|
||||
<v-chip :tabindex="tabIndex" size="small" class="px-0" label>
|
||||
<v-chip label>{{ field.label }}</v-chip>
|
||||
<span class="px-2">{{
|
||||
field.format(currentPlatform[field.key]) || "N/A"
|
||||
@@ -395,10 +409,12 @@ watch(
|
||||
variant="text"
|
||||
class="ml-2 mt-2"
|
||||
prepend-icon="mdi-aspect-ratio"
|
||||
:tabindex="tabIndex"
|
||||
>{{ t("platform.cover-style") }}</v-chip
|
||||
>
|
||||
<v-divider class="border-opacity-25 mx-2" />
|
||||
<v-item-group
|
||||
:tabindex="tabIndex"
|
||||
v-model="selectedAspectRatio"
|
||||
mandatory
|
||||
@update:model-value="setAspectRatio"
|
||||
@@ -456,6 +472,7 @@ watch(
|
||||
<template #content>
|
||||
<div class="text-center">
|
||||
<v-btn
|
||||
:tabindex="tabIndex"
|
||||
class="text-romm-red bg-toplayer ma-2"
|
||||
variant="flat"
|
||||
@click="emitter?.emit('showDeletePlatformDialog', currentPlatform)"
|
||||
|
||||
@@ -14,7 +14,7 @@ const { activePlatformInfoDrawer } = storeToRefs(navigationStore);
|
||||
location="bottom"
|
||||
class="tooltip"
|
||||
transition="fade-transition"
|
||||
:text="t('platform.show-firmwares')"
|
||||
:text="t('platform.show-platform-settings')"
|
||||
open-delay="1000"
|
||||
>
|
||||
<template #activator="{ props }">
|
||||
@@ -24,6 +24,7 @@ const { activePlatformInfoDrawer } = storeToRefs(navigationStore);
|
||||
v-bind="props"
|
||||
icon="mdi-cog"
|
||||
:color="activePlatformInfoDrawer ? 'primary' : ''"
|
||||
aria-label="Platform settings"
|
||||
@click="navigationStore.switchActivePlatformInfoDrawer()"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -100,6 +100,7 @@ watch(
|
||||
slider-color="primary"
|
||||
bg-color="surface"
|
||||
direction="vertical"
|
||||
tabindex="-1"
|
||||
>
|
||||
<v-tab
|
||||
v-for="char in Object.keys(characterIndex)"
|
||||
|
||||
@@ -31,6 +31,7 @@ const { activeFilterDrawer } = storeToRefs(galleryFilterStore);
|
||||
? 'secondary'
|
||||
: ''
|
||||
"
|
||||
aria-label="Filter"
|
||||
@click="galleryFilterStore.switchActiveFilterDrawer()" /></template
|
||||
></v-tooltip>
|
||||
</template>
|
||||
|
||||
@@ -185,21 +185,38 @@ onMounted(async () => {
|
||||
}"
|
||||
class="bg-surface rounded mt-4 mb-2 pa-1 unset-height"
|
||||
>
|
||||
<v-list>
|
||||
<v-list tabindex="-1">
|
||||
<template v-if="showFilterBar && xs">
|
||||
<v-list-item>
|
||||
<filter-text-field />
|
||||
<filter-text-field :tabindex="activeFilterDrawer ? 0 : -1" />
|
||||
</v-list-item>
|
||||
</template>
|
||||
<v-list-item>
|
||||
<filter-unmatched-btn />
|
||||
<filter-matched-btn class="mt-2" />
|
||||
<filter-favourites-btn class="mt-2" />
|
||||
<filter-duplicates-btn class="mt-2" />
|
||||
<filter-playables-btn v-if="showPlayablesFilter" class="mt-2" />
|
||||
<filter-unmatched-btn :tabindex="activeFilterDrawer ? 0 : -1" />
|
||||
<filter-matched-btn
|
||||
class="mt-2"
|
||||
:tabindex="activeFilterDrawer ? 0 : -1"
|
||||
/>
|
||||
<filter-favourites-btn
|
||||
class="mt-2"
|
||||
:tabindex="activeFilterDrawer ? 0 : -1"
|
||||
/>
|
||||
<filter-duplicates-btn
|
||||
class="mt-2"
|
||||
:tabindex="activeFilterDrawer ? 0 : -1"
|
||||
/>
|
||||
<filter-playables-btn
|
||||
v-if="showPlayablesFilter"
|
||||
class="mt-2"
|
||||
:tabindex="activeFilterDrawer ? 0 : -1"
|
||||
/>
|
||||
</v-list-item>
|
||||
<v-list-item v-if="showPlatformsFilter">
|
||||
<v-list-item
|
||||
v-if="showPlatformsFilter"
|
||||
:tabindex="activeFilterDrawer ? 0 : -1"
|
||||
>
|
||||
<v-autocomplete
|
||||
:tabindex="activeFilterDrawer ? 0 : -1"
|
||||
v-model="selectedPlatform"
|
||||
hide-details
|
||||
prepend-inner-icon="mdi-controller"
|
||||
@@ -248,9 +265,13 @@ onMounted(async () => {
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
</v-list-item>
|
||||
<v-list-item v-for="filter in filters">
|
||||
<v-list-item
|
||||
v-for="filter in filters"
|
||||
:tabindex="activeFilterDrawer ? 0 : -1"
|
||||
>
|
||||
<v-autocomplete
|
||||
v-model="filter.selected.value"
|
||||
:tabindex="activeFilterDrawer ? 0 : -1"
|
||||
hide-details
|
||||
clearable
|
||||
:label="filter.label"
|
||||
@@ -260,8 +281,16 @@ onMounted(async () => {
|
||||
@update:model-value="nextTick(() => emitter?.emit('filter', null))"
|
||||
/>
|
||||
</v-list-item>
|
||||
<v-list-item class="justify-center d-flex">
|
||||
<v-btn size="small" variant="tonal" @click="resetFilters">
|
||||
<v-list-item
|
||||
class="justify-center d-flex"
|
||||
:tabindex="activeFilterDrawer ? 0 : -1"
|
||||
>
|
||||
<v-btn
|
||||
:tabindex="activeFilterDrawer ? 0 : -1"
|
||||
size="small"
|
||||
variant="tonal"
|
||||
@click="resetFilters"
|
||||
>
|
||||
{{ t("platform.reset-filters") }}
|
||||
</v-btn>
|
||||
</v-list-item>
|
||||
|
||||
@@ -54,7 +54,6 @@ watch(
|
||||
<v-text-field
|
||||
:density="xs ? 'comfortable' : 'default'"
|
||||
clearable
|
||||
autofocus
|
||||
hide-details
|
||||
rounded="0"
|
||||
:label="t('common.filter')"
|
||||
|
||||
@@ -23,6 +23,7 @@ const galleryView = storeGalleryView();
|
||||
rounded="0"
|
||||
class="mr-0"
|
||||
:icon="views[galleryView.currentView]['icon']"
|
||||
aria-label="Change view"
|
||||
@click="galleryView.next()" /></template
|
||||
></v-tooltip>
|
||||
</template>
|
||||
|
||||
@@ -23,6 +23,7 @@ const romsStore = storeRoms();
|
||||
v-bind="props"
|
||||
class="mr-0"
|
||||
icon="mdi-select-group"
|
||||
aria-label="Multi select"
|
||||
@click="romsStore.setSelecting()" /></template
|
||||
></v-tooltip>
|
||||
</template>
|
||||
|
||||
@@ -25,7 +25,11 @@ function toggleGridCollections() {
|
||||
<template>
|
||||
<r-section icon="mdi-bookmark-box-multiple" :title="t('common.collections')">
|
||||
<template #toolbar-append>
|
||||
<v-btn icon rounded="0" @click="toggleGridCollections"
|
||||
<v-btn
|
||||
aria-label="Toggle collections grid view"
|
||||
icon
|
||||
rounded="0"
|
||||
@click="toggleGridCollections"
|
||||
><v-icon>{{
|
||||
gridCollections ? "mdi-view-comfy" : "mdi-view-column"
|
||||
}}</v-icon>
|
||||
|
||||
@@ -29,7 +29,11 @@ function toggleGridContinuePlaying() {
|
||||
<template>
|
||||
<r-section icon="mdi-play" :title="t('home.continue-playing')">
|
||||
<template #toolbar-append>
|
||||
<v-btn icon rounded="0" @click="toggleGridContinuePlaying"
|
||||
<v-btn
|
||||
aria-label="Toggle continue playing games grid view"
|
||||
icon
|
||||
rounded="0"
|
||||
@click="toggleGridContinuePlaying"
|
||||
><v-icon>{{
|
||||
gridContinuePlayingRoms ? "mdi-view-comfy" : "mdi-view-column"
|
||||
}}</v-icon>
|
||||
|
||||
@@ -27,7 +27,11 @@ function toggleGridPlatforms() {
|
||||
<template>
|
||||
<r-section icon="mdi-controller" :title="t('common.platforms')">
|
||||
<template #toolbar-append>
|
||||
<v-btn icon rounded="0" @click="toggleGridPlatforms"
|
||||
<v-btn
|
||||
aria-label="Toggle platforms grid view"
|
||||
icon
|
||||
rounded="0"
|
||||
@click="toggleGridPlatforms"
|
||||
><v-icon>{{
|
||||
gridPlatforms ? "mdi-view-comfy" : "mdi-view-column"
|
||||
}}</v-icon>
|
||||
|
||||
@@ -27,7 +27,11 @@ function toggleGridRecentRoms() {
|
||||
<template>
|
||||
<r-section icon="mdi-shimmer" :title="t('home.recently-added')">
|
||||
<template #toolbar-append>
|
||||
<v-btn icon rounded="0" @click="toggleGridRecentRoms"
|
||||
<v-btn
|
||||
aria-label="Toggle recently games added grid view"
|
||||
icon
|
||||
rounded="0"
|
||||
@click="toggleGridRecentRoms"
|
||||
><v-icon>{{
|
||||
gridRecentRoms ? "mdi-view-comfy" : "mdi-view-column"
|
||||
}}</v-icon>
|
||||
|
||||
@@ -67,6 +67,7 @@ watch(menuOpen, (val) => {
|
||||
variant="text"
|
||||
rounded="0"
|
||||
@click.prevent="romApi.downloadRom({ rom })"
|
||||
:aria-label="`Download ${rom.name}`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col
|
||||
@@ -87,6 +88,7 @@ watch(menuOpen, (val) => {
|
||||
icon="mdi-play"
|
||||
variant="text"
|
||||
rounded="0"
|
||||
:aria-label="`Play ${rom.name}`"
|
||||
/>
|
||||
<v-btn
|
||||
v-if="ruffleEmulationSupported"
|
||||
@@ -102,6 +104,7 @@ watch(menuOpen, (val) => {
|
||||
icon="mdi-play"
|
||||
variant="text"
|
||||
rounded="0"
|
||||
:aria-label="`Play ${rom.name}`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col v-if="is3DSRom" class="d-flex">
|
||||
@@ -113,6 +116,7 @@ watch(menuOpen, (val) => {
|
||||
icon="mdi-qrcode"
|
||||
variant="text"
|
||||
rounded="0"
|
||||
:aria-label="`Show ${rom.name} QR code`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col
|
||||
@@ -133,6 +137,7 @@ watch(menuOpen, (val) => {
|
||||
icon="mdi-dots-vertical"
|
||||
variant="text"
|
||||
rounded="0"
|
||||
:aria-label="`${rom.name} admin menu`"
|
||||
/>
|
||||
</template>
|
||||
<admin-menu :rom="rom" />
|
||||
|
||||
@@ -116,6 +116,7 @@ const showActionBarAlways = isNull(
|
||||
'transform-scale': transformScale,
|
||||
}"
|
||||
:elevation="isOuterHovering && transformScale ? 20 : 3"
|
||||
:aria-label="`${rom.name} game card`"
|
||||
>
|
||||
<v-card-text class="pa-0">
|
||||
<v-progress-linear
|
||||
@@ -201,7 +202,7 @@ const showActionBarAlways = isNull(
|
||||
collectionsStore.isFav(rom) &&
|
||||
showFav
|
||||
"
|
||||
@click.stop=""
|
||||
tabindex="-1"
|
||||
class="label-fav"
|
||||
rouded="0"
|
||||
size="small"
|
||||
|
||||
@@ -6,7 +6,7 @@ import storeNavigation from "@/stores/navigation";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { inject, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import { inject, onBeforeUnmount, onMounted, ref, watch, computed } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { isNull } from "lodash";
|
||||
@@ -21,6 +21,7 @@ const { filteredCollections, filteredVirtualCollections, filterText } =
|
||||
const { activeCollectionsDrawer } = storeToRefs(navigationStore);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const visibleVirtualCollections = ref(72);
|
||||
const tabIndex = computed(() => (activeCollectionsDrawer.value ? 0 : -1));
|
||||
|
||||
const showVirtualCollections = isNull(
|
||||
localStorage.getItem("settings.showVirtualCollections"),
|
||||
@@ -79,13 +80,10 @@ onBeforeUnmount(() => {
|
||||
collectionsDrawer?.removeEventListener("scroll", onScroll);
|
||||
});
|
||||
|
||||
// Close the drawer when the Esc key is pressed
|
||||
function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") {
|
||||
activeCollectionsDrawer.value = false;
|
||||
// Focus the element that triggered the drawer
|
||||
triggerElement.value?.focus();
|
||||
}
|
||||
function onClose() {
|
||||
activeCollectionsDrawer.value = false;
|
||||
// Focus the element that triggered the drawer
|
||||
triggerElement.value?.focus();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
@@ -106,13 +104,13 @@ function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
class="bg-surface pa-1"
|
||||
rounded
|
||||
:border="1"
|
||||
@keydown="handleDrawerCloseOnEsc"
|
||||
@keydown.esc="onClose"
|
||||
>
|
||||
<template #prepend>
|
||||
<v-text-field
|
||||
ref="textFieldRef"
|
||||
aria-label="Search collection"
|
||||
:tabindex="activeCollectionsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
v-model="filterText"
|
||||
prepend-inner-icon="mdi-filter-outline"
|
||||
clearable
|
||||
@@ -130,7 +128,7 @@ function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
v-for="collection in filteredCollections"
|
||||
:collection="collection"
|
||||
with-link
|
||||
:tabindex="activeCollectionsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
role="listitem"
|
||||
:aria-label="`${collection.name}`"
|
||||
/>
|
||||
@@ -141,7 +139,7 @@ function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
<v-list-subheader
|
||||
role="listitem"
|
||||
:aria-label="t('common.virtual-collections')"
|
||||
:tabindex="activeCollectionsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
class="uppercase"
|
||||
>{{ t("common.virtual-collections").toUpperCase() }}</v-list-subheader
|
||||
>
|
||||
@@ -153,7 +151,7 @@ function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
:collection="collection"
|
||||
with-link
|
||||
role="listitem"
|
||||
:tabindex="activeCollectionsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
:aria-label="`${collection.name} with ${collection.rom_count} games`"
|
||||
/>
|
||||
</template>
|
||||
@@ -164,7 +162,7 @@ function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
variant="tonal"
|
||||
color="primary"
|
||||
prepend-icon="mdi-plus"
|
||||
:tabindex="activeCollectionsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
size="large"
|
||||
block
|
||||
>
|
||||
|
||||
@@ -5,7 +5,7 @@ import storePlatforms from "@/stores/platforms";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ref, watch } from "vue";
|
||||
import { ref, watch, computed } from "vue";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
@@ -14,6 +14,7 @@ const { mdAndUp, smAndDown } = useDisplay();
|
||||
const platformsStore = storePlatforms();
|
||||
const { filteredPlatforms, filterText } = storeToRefs(platformsStore);
|
||||
const { activePlatformsDrawer } = storeToRefs(navigationStore);
|
||||
const tabIndex = computed(() => (activePlatformsDrawer.value ? 0 : -1));
|
||||
|
||||
// Functions
|
||||
function clear() {
|
||||
@@ -33,13 +34,10 @@ watch(activePlatformsDrawer, (isOpen) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Close the drawer when the Esc key is pressed
|
||||
function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") {
|
||||
activePlatformsDrawer.value = false;
|
||||
// Focus the element that triggered the drawer
|
||||
triggerElement.value?.focus();
|
||||
}
|
||||
function onClose() {
|
||||
activePlatformsDrawer.value = false;
|
||||
// Focus the element that triggered the drawer
|
||||
triggerElement.value?.focus();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
@@ -59,13 +57,13 @@ function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
class="bg-surface pa-1"
|
||||
rounded
|
||||
:border="0"
|
||||
@keydown="handleDrawerCloseOnEsc"
|
||||
@keydown.esc="onClose"
|
||||
>
|
||||
<template #prepend>
|
||||
<v-text-field
|
||||
ref="textFieldRef"
|
||||
aria-label="Search platform"
|
||||
:tabindex="activePlatformsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
v-model="filterText"
|
||||
prepend-inner-icon="mdi-filter-outline"
|
||||
clearable
|
||||
@@ -83,7 +81,7 @@ function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
v-for="platform in filteredPlatforms"
|
||||
:key="platform.slug"
|
||||
:platform="platform"
|
||||
:tabindex="activePlatformsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
role="listitem"
|
||||
:aria-label="`${platform.display_name} with ${platform.rom_count} games`"
|
||||
/>
|
||||
|
||||
@@ -9,7 +9,7 @@ import { defaultAvatarPath, getRoleIcon } from "@/utils";
|
||||
import { ROUTES } from "@/plugins/router";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs, getActivePinia, type StateTree } from "pinia";
|
||||
import { inject, ref, watch } from "vue";
|
||||
import { inject, ref, watch, computed } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { useI18n } from "vue-i18n";
|
||||
@@ -23,6 +23,7 @@ const { user, scopes } = storeToRefs(auth);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const { activeSettingsDrawer } = storeToRefs(navigationStore);
|
||||
const { smAndDown, mdAndUp } = useDisplay();
|
||||
const tabIndex = computed(() => (activeSettingsDrawer.value ? 0 : -1));
|
||||
|
||||
// Functions
|
||||
async function logout() {
|
||||
@@ -50,23 +51,17 @@ async function logout() {
|
||||
// Ref to store the element that triggered the drawer
|
||||
const triggerElement = ref<HTMLElement | null>(null);
|
||||
// Watch for changes in the navigation drawer state
|
||||
const firstElementRef = ref();
|
||||
watch(activeSettingsDrawer, (isOpen) => {
|
||||
if (isOpen) {
|
||||
// Store the currently focused element before opening the drawer
|
||||
triggerElement.value = document.activeElement as HTMLElement;
|
||||
// Focus the first element when the drawer is opened
|
||||
firstElementRef.value?.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// Close the drawer when the Esc key is pressed
|
||||
function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") {
|
||||
activeSettingsDrawer.value = false;
|
||||
// Focus the element that triggered the drawer
|
||||
triggerElement.value?.focus();
|
||||
}
|
||||
function onClose() {
|
||||
activeSettingsDrawer.value = false;
|
||||
// Focus the element that triggered the drawer
|
||||
triggerElement.value?.focus();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
@@ -83,7 +78,7 @@ function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
class="bg-surface pa-1 unset-height"
|
||||
rounded
|
||||
:border="0"
|
||||
@keydown="handleDrawerCloseOnEsc"
|
||||
@keydown.esc="onClose"
|
||||
>
|
||||
<v-list tabindex="-1" class="pa-0">
|
||||
<v-list-img>
|
||||
@@ -107,49 +102,57 @@ function handleDrawerCloseOnEsc(event: KeyboardEvent) {
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
<v-list class="py-1 px-0">
|
||||
<v-list tabindex="-1" class="py-1 px-0">
|
||||
<v-list-item
|
||||
v-if="scopes.includes('me.write')"
|
||||
ref="firstElementRef"
|
||||
:tabindex="activeSettingsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
rounded
|
||||
:to="{ name: ROUTES.USER_PROFILE, params: { user: user?.id } }"
|
||||
append-icon="mdi-account"
|
||||
aria-label="Profile"
|
||||
role="listitem"
|
||||
>{{ t("common.profile") }}</v-list-item
|
||||
>
|
||||
<v-list-item
|
||||
:tabindex="activeSettingsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
class="mt-1"
|
||||
rounded
|
||||
:to="{ name: ROUTES.USER_INTERFACE }"
|
||||
append-icon="mdi-palette"
|
||||
aria-label="User Interface"
|
||||
role="listitem"
|
||||
>{{ t("common.user-interface") }}</v-list-item
|
||||
>
|
||||
<v-list-item
|
||||
v-if="scopes.includes('platforms.write')"
|
||||
:tabindex="activeSettingsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
class="mt-1"
|
||||
rounded
|
||||
append-icon="mdi-table-cog"
|
||||
aria-label="Library management"
|
||||
role="listitem"
|
||||
:to="{ name: ROUTES.LIBRARY_MANAGEMENT }"
|
||||
>{{ t("common.library-management") }}
|
||||
</v-list-item>
|
||||
<v-list-item
|
||||
v-if="scopes.includes('users.write')"
|
||||
:tabindex="activeSettingsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
class="mt-1"
|
||||
rounded
|
||||
:to="{ name: ROUTES.ADMINISTRATION }"
|
||||
append-icon="mdi-security"
|
||||
aria-label="Administration"
|
||||
role="listitem"
|
||||
>{{ t("common.administration") }}
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
<template v-if="scopes.includes('me.write')" #append>
|
||||
<v-btn
|
||||
@click="logout"
|
||||
:tabindex="activeSettingsDrawer ? 0 : -1"
|
||||
:tabindex="tabIndex"
|
||||
append-icon="mdi-location-exit"
|
||||
block
|
||||
aria-label="Logout"
|
||||
class="bg-toplayer text-romm-red"
|
||||
>{{ t("common.logout") }}</v-btn
|
||||
>
|
||||
|
||||
@@ -13,6 +13,7 @@ const { smAndDown } = useDisplay();
|
||||
</script>
|
||||
<template>
|
||||
<v-avatar
|
||||
@keydown.enter="navigationStore.switchActiveSettingsDrawer"
|
||||
@click="navigationStore.switchActiveSettingsDrawer"
|
||||
class="pointer"
|
||||
:size="smAndDown ? 35 : 40"
|
||||
|
||||
Reference in New Issue
Block a user