fix(a11y): translate the v2 primitives' own control labels (#4620)

* fix(a11y): translate the v2 primitives' own control labels

The library hard-coded 20 English strings for controls a primitive
renders on its own behalf, so screen-reader users heard English in every
locale: close on RDialog/RDrawer/RCarousel, remove on RChip/RSelect/
RComboboxField, clear on RTextField/RSelect/RComboboxField/RDateField,
RDateField's picker toggle and four month/year steppers, plus the
visible "Today" and "All" text.

The overridable-prop pattern was already there and had already failed:
RCarousel's closeLabel/prevLabel/nextLabel and RDateField's
clearLabel/todayLabel defaulted to English literals and no call site
ever passed one. Extending it would have made translation depend on
roughly 130 call sites each remembering to pass a label for a string
that is identical at every one of them.

Instead the app provides one bundle and every primitive reads it through
useChromeLabels(). The provider hands over getters that resolve via
i18n, so they run inside the reading component's render effect and a
locale switch re-renders the labels with no refs to unwrap. inject is
plain Vue, so lib still imports no i18n, and the English defaults keep a
bare mount rendering an accessible name. The existing label props stay
as per-instance overrides, now defaulting to undefined so they resolve
through the bundle.

Reuses common.close, common.clear, common.remove and common.all; adds
eight common.* keys across all 18 locales for the date-field steppers
and carousel navigation. setup.previous/next were left alone: they are
wizard step semantics ("previous step", "back"), not item navigation.

Storybook provides the same bundle, so stories exercise the real path.
Two tests guard the decay this had already suffered once: that an
injected bundle reaches a primitive's aria-label, and that every label
resolves to a real translation in every locale.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENyaGKiTZiwPGH7qyN4iMe

* refactor: tighten the chrome-label comments and use import.meta.url

Condense the module header and the test's header to the repo's comment
limit, and derive the locales directory from import.meta.url rather than
__dirname, matching the review feedback on #4619.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENyaGKiTZiwPGH7qyN4iMe

* fix(a11y): cover RAlert and RSteps, and test the real locale switch

RAlert's close button and RSteps' stepper name were missed on the first
pass: RAlert writes its label as a bound string literal
(:aria-label="'Close'") and RSteps builds "Step 2 of 5" from a template
string, neither of which the plain aria-label="Text" scan matched. Both
now read the injected bundle, which gains a step(current, total) member
backed by common.step-of across all 18 locales.

The locale-propagation test previously flipped a local variable and
called $forceUpdate, which only proved a getter re-reads on render. It
now mounts against createChromeLabels(), switches i18n.global.locale and
asserts the rendered label changes on its own, so it exercises the path
the app actually uses. RAlert and RSteps get assertions of their own.

Wrap the new skill bullet so it stops adding a markdownlint line-length
violation, and drop three comments that only restated the ?? beside them.

Reported by Copilot (RAlert) and Greptile (test, comments) on #4620.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENyaGKiTZiwPGH7qyN4iMe

* fix(a11y): put RDateField's combobox role on its focusable input

The role sat on the field's wrapper div, which is not focusable and had
no aria-controls, so the two accessibility lints on it were right:
assistive tech saw a combobox it could not reach and that pointed at no
popup. The previous comment explained why the role could not go on
RTextField, and it was accurate: RTextField binds $attrs to its outer
element, which becomes a <label> when it owns the visible label, where
the role is disallowed.

So give RTextField a typed `popup` prop that lands role="combobox",
aria-haspopup, aria-expanded and aria-controls on the native input,
where ARIA 1.2 wants them. A single object prop rather than an attribute
bag keeps arbitrary attributes off the input. RDateField passes it,
drops the role from the wrapper (keeping the keydown handler, which is
what the wrapper is actually for) and gives the teleported panel a
useId() so aria-controls resolves.

The wrapper never was a tab stop, so no tab order changes: the input it
delegates to is the same element that now carries the role.

Covers the two vuejs-accessibility errors that eslint reported against
this file on master; src/v2/lib is now lint-clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENyaGKiTZiwPGH7qyN4iMe

* fix(a11y): make popup and multiline exclusive, and tighten comments

The new `popup` prop rendered its combobox attributes only on the
<input> branch, so a caller that also set `multiline` type-checked but
got a plain <textarea> with none of the role, expanded state or popup
association it asked for. Binding them to the textarea instead is not an
option: ARIA in HTML allows no role override on <textarea>, so
role=combobox there would be invalid. The conflict now reports itself
through console.error rather than dropping the ARIA in silence, and the
prop documents the single-line constraint.

Adds RTextField.test.ts covering all three cases: the role landing on
the input while the <label> outer element stays clear of it, no
combobox attributes when the prop is absent, and the conflict being
reported.

Also drop a sentence recording what the code used to do, which CLAUDE.md
rules out, and shorten the RDateField template comment.

Reported by Greptile (both P2) on #4621.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENyaGKiTZiwPGH7qyN4iMe

* chore(deps): declare the Vue 3.5 floor the code already requires

useId lands in Vue 3.5 and RComboboxField has been calling it on master,
so the declared ^3.4.27 range understated the real minimum: a resolution
inside 3.4 would fail to build. The lockfile already pins 3.5.29, so
this only corrects the manifest and changes no resolved version.

RTextField carried a comment claiming the project was "on 3.4 still",
which is what made useId look like a regression in review; it is gone,
and the architecture doc's framework row now matches.

Also stop advertising aria-controls while the picker is closed. The
panel is v-if'd, so the input pointed at an element that was not in the
document; `controls` is now optional and RDateField passes it only while
the panel is mounted, with the closed state asserted.

Reported by Copilot on #4621.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENyaGKiTZiwPGH7qyN4iMe

* refactor: drop a comment recording what the code used to do

The describe name already states what the block verifies, and the rest
was change history, which CLAUDE.md rules out.

Reported by Greptile on #4620.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENyaGKiTZiwPGH7qyN4iMe

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Sam Dornan
2026-09-18 10:19:33 -05:00
committed by GitHub
parent 3ca50f6d25
commit ffd26fe6dc
40 changed files with 698 additions and 62 deletions

View File

@@ -46,6 +46,17 @@ If any fails: **shared composite** if generic across features, **feature composi
- **Can use**: tokens, other primitives, Vue, generic composables (`useInput*`, `useFocus*`).
- **Cannot use**: Pinia stores, API services, `emitter`, `router` (a `RouterLink` may be accepted as a prop), `i18n` directly. **No `$t()` in primitives** — text comes via props or slots.
- **Chrome labels** are the exception to "via props": the accessible name
of a control the primitive renders for itself (a dialog's close button, a
chip's remove X, a date field's steppers, a stepper's "Step 2 of 5") is
not caller-supplied content, and a per-instance prop for it has to be
passed at every call site to have any effect. Read them from
`useChromeLabels()` (`lib/a11y/chromeLabels.ts`), which the app fills with
translations via `app.provide` and which falls back to English when
unprovided. Never hard-code an `aria-label` string (including a bound
literal like `:aria-label="'Close'"`) or an English prop default in
`lib/`. A label prop may still exist as a per-instance override,
defaulting to `undefined` so it resolves through the bundle.
---

View File

@@ -31,20 +31,20 @@ Comprehensive documentation of the RomM frontend: a Vue 3 single-page applicatio
## 1. Overview
| Property | Value |
| -------------------- | ---------------------------------------------- |
| **Framework** | Vue 3.4.27 (Composition API, `<script setup>`) |
| **Build Tool** | Vite 6.4.2 |
| **Language** | TypeScript 5.7.3 (`noImplicitAny: true`) |
| **UI Library** | Vuetify 3.9.2 (Material Design), v1 only |
| **CSS** | Tailwind CSS 4.3.1 + Vuetify themes, v1 only |
| **State Management** | Pinia 3.0.1 (18 stores) |
| **Routing** | Vue Router 4.3.2 |
| **HTTP Client** | Axios 1.15.0 |
| **i18n** | vue-i18n 11.1.10 (17 languages) |
| **Real-time** | Socket.IO Client 4.7.5 |
| **Icons** | Material Design Icons (MDI) 7.4.47 |
| **Node** | 24 (via `.nvmrc`) |
| Property | Value |
| -------------------- | -------------------------------------------- |
| **Framework** | Vue 3.5 (Composition API, `<script setup>`) |
| **Build Tool** | Vite 6.4.2 |
| **Language** | TypeScript 5.7.3 (`noImplicitAny: true`) |
| **UI Library** | Vuetify 3.9.2 (Material Design), v1 only |
| **CSS** | Tailwind CSS 4.3.1 + Vuetify themes, v1 only |
| **State Management** | Pinia 3.0.1 (18 stores) |
| **Routing** | Vue Router 4.3.2 |
| **HTTP Client** | Axios 1.15.0 |
| **i18n** | vue-i18n 11.1.10 (17 languages) |
| **Real-time** | Socket.IO Client 4.7.5 |
| **Icons** | Material Design Icons (MDI) 7.4.47 |
| **Node** | 24 (via `.nvmrc`) |
**Total:** ~216 Vue components (168 under `components/`, rest in views/console/layouts), 18 Pinia stores, 17 API service modules, 36 named routes across 3 layouts.

View File

@@ -10,7 +10,9 @@ import storePermissions from "../src/stores/permissions";
import "../src/styles/common.css";
import "../src/styles/fonts.css";
import { dark, light } from "../src/styles/themes";
import { ChromeLabelsKey } from "../src/v2/lib/a11y/chromeLabels";
import "../src/v2/styles/global.css";
import { createChromeLabels } from "../src/v2/utils/chromeLabels";
// Each story runs inside a Vue app with Pinia + i18n + Vuetify registered.
// v2 primitives are Vuetify-free at runtime — Vuetify stays registered only
@@ -25,6 +27,9 @@ import "../src/v2/styles/global.css";
setup((app) => {
app.use(createPinia());
app.use(i18n);
// Stories exercise the same injected-label path as the app, so a
// primitive rendering an un-translated label fails here too.
app.provide(ChromeLabelsKey, createChromeLabels());
// A catch-all router so primitives that render real `<router-link>`s
// (RBtn / RListItem / RMenuItem with `to`) resolve a proper `href`
// instead of crashing on `router.resolve`. Any string path resolves.

View File

@@ -28,7 +28,7 @@
"socket.io-client": "^4.7.5",
"tailwindcss": "^4.0.0",
"vanilla-tilt": "^1.8.1",
"vue": "^3.4.27",
"vue": "^3.5.0",
"vue-i18n": "^11.1.10",
"vue-router": "^4.3.2",
"vue3-pdf-app": "^1.0.3",

View File

@@ -57,7 +57,7 @@
"socket.io-client": "^4.7.5",
"tailwindcss": "^4.0.0",
"vanilla-tilt": "^1.8.1",
"vue": "^3.4.27",
"vue": "^3.5.0",
"vue-i18n": "^11.1.10",
"vue-router": "^4.3.2",
"vue3-pdf-app": "^1.0.3",

View File

@@ -45,6 +45,7 @@
"core": "Основни",
"create": "Създай",
"crt-mode": "CRT mode",
"date-picker": "Избор на дата",
"decade-mix": "Микс по десетилетия",
"decades-n": "{n} десетилетие | {n} десетилетия",
"delete": "Изтрий",
@@ -97,7 +98,10 @@
"music-by-artist": "Саундтраци по изпълнител",
"name": "Име",
"new-version-available": "Налична е нова версия",
"next": "Следващ",
"next-month": "Следващ месец",
"next-page": "Следваща страница",
"next-year": "Следваща година",
"no-cover": "Без корица",
"no-results": "Няма резултати",
"not-linked": "Не е свързано",
@@ -115,7 +119,10 @@
"platforms-n": "{n} платформа | {n} платформи",
"play-all": "Пусни всички",
"playlists": "Плейлисти",
"previous": "Предишен",
"previous-month": "Предходен месец",
"previous-page": "Предишна страница",
"previous-year": "Предходна година",
"primary-navigation": "Основна навигация",
"profile": "Профил",
"random": "Случайно",
@@ -152,8 +159,10 @@
"state": "Състояние",
"states": "Състояния",
"states-n": "{n} състояние | {n} състояния",
"step-of": "Стъпка {current} от {total}",
"switch-classic-ui": "Превключи към класическия интерфейс",
"sync": "Синхронизирай",
"today": "Днес",
"try-again": "Опитай отново",
"type": "Тип",
"type-to-confirm": "Напиши {label}, за да потвърдиш.",

View File

@@ -45,6 +45,7 @@
"core": "Jádro",
"create": "Vytvořit",
"crt-mode": "CRT mode",
"date-picker": "Výběr data",
"decade-mix": "Mix desetiletí",
"decades-n": "{n} desetiletí | {n} desetiletí",
"delete": "Smazat",
@@ -97,7 +98,10 @@
"music-by-artist": "Soundtracky podle interpreta",
"name": "Název",
"new-version-available": "Je k dispozici nová verze",
"next": "Další",
"next-month": "Další měsíc",
"next-page": "Další stránka",
"next-year": "Další rok",
"no-cover": "Bez obalu",
"no-results": "Žádné výsledky",
"not-linked": "Nepropojeno",
@@ -115,7 +119,10 @@
"platforms-n": "{n} platforma | {n} platformy",
"play-all": "Přehrát vše",
"playlists": "Playlisty",
"previous": "Předchozí",
"previous-month": "Předchozí měsíc",
"previous-page": "Předchozí stránka",
"previous-year": "Předchozí rok",
"primary-navigation": "Hlavní navigace",
"profile": "Profil",
"random": "Náhodně",
@@ -152,8 +159,10 @@
"state": "Stav",
"states": "Stavy",
"states-n": "{n} stavů | {n} stav | {n} stavy | {n} stavů",
"step-of": "Krok {current} z {total}",
"switch-classic-ui": "Přepnout na klasické rozhraní",
"sync": "Synchronizovat",
"today": "Dnes",
"try-again": "Zkusit znovu",
"type": "Typ",
"type-to-confirm": "Pro potvrzení napište {label}.",

View File

@@ -45,6 +45,7 @@
"core": "Core",
"create": "Erstellen",
"crt-mode": "CRT-Modus",
"date-picker": "Datumsauswahl",
"decade-mix": "Jahrzehnte-Mix",
"decades-n": "{n} Jahrzehnt | {n} Jahrzehnte",
"delete": "Löschen",
@@ -97,7 +98,10 @@
"music-by-artist": "Soundtracks nach Künstler",
"name": "Name",
"new-version-available": "Neue Version verfügbar",
"next": "Weiter",
"next-month": "Nächster Monat",
"next-page": "Nächste Seite",
"next-year": "Nächstes Jahr",
"no-cover": "Kein Cover",
"no-results": "Keine Ergebnisse",
"not-linked": "Nicht verknüpft",
@@ -115,7 +119,10 @@
"platforms-n": "{n} Plattform | {n} Plattformen",
"play-all": "Alle abspielen",
"playlists": "Wiedergabelisten",
"previous": "Zurück",
"previous-month": "Vorheriger Monat",
"previous-page": "Vorherige Seite",
"previous-year": "Vorheriges Jahr",
"primary-navigation": "Hauptnavigation",
"profile": "Profil",
"random": "Zufällig",
@@ -152,8 +159,10 @@
"state": "Spielstand",
"states": "Spielstände",
"states-n": "{n} Spielstand | {n} Spielstände",
"step-of": "Schritt {current} von {total}",
"switch-classic-ui": "Zur klassischen Oberfläche wechseln",
"sync": "Synchronisieren",
"today": "Heute",
"try-again": "Erneut versuchen",
"type": "Typ",
"type-to-confirm": "Tippe {label} zur Bestätigung.",

View File

@@ -45,6 +45,7 @@
"core": "Core",
"create": "Create",
"crt-mode": "CRT mode",
"date-picker": "Date picker",
"decade-mix": "Decade Mix",
"decades-n": "{n} decade | {n} decades",
"delete": "Delete",
@@ -97,7 +98,10 @@
"music-by-artist": "Soundtracks by Artist",
"name": "Name",
"new-version-available": "New version available",
"next": "Next",
"next-month": "Next month",
"next-page": "Next page",
"next-year": "Next year",
"no-cover": "No cover",
"no-results": "No results",
"not-linked": "Not linked",
@@ -115,7 +119,10 @@
"platforms-n": "{n} platform | {n} platforms",
"play-all": "Play all",
"playlists": "Playlists",
"previous": "Previous",
"previous-month": "Previous month",
"previous-page": "Previous page",
"previous-year": "Previous year",
"primary-navigation": "Primary navigation",
"profile": "Profile",
"random": "Random",
@@ -152,8 +159,10 @@
"state": "State",
"states": "States",
"states-n": "{n} State | {n} States",
"step-of": "Step {current} of {total}",
"switch-classic-ui": "Switch to classic UI",
"sync": "Sync",
"today": "Today",
"try-again": "Try again",
"type": "Type",
"type-to-confirm": "Type {label} to confirm.",

View File

@@ -45,6 +45,7 @@
"core": "Core",
"create": "Create",
"crt-mode": "CRT mode",
"date-picker": "Date picker",
"decade-mix": "Decade Mix",
"decades-n": "{n} decade | {n} decades",
"delete": "Delete",
@@ -97,7 +98,10 @@
"music-by-artist": "Soundtracks by Artist",
"name": "Name",
"new-version-available": "New version available",
"next": "Next",
"next-month": "Next month",
"next-page": "Next page",
"next-year": "Next year",
"no-cover": "No cover",
"no-results": "No results",
"not-linked": "Not linked",
@@ -115,7 +119,10 @@
"platforms-n": "{n} platform | {n} platforms",
"play-all": "Play all",
"playlists": "Playlists",
"previous": "Previous",
"previous-month": "Previous month",
"previous-page": "Previous page",
"previous-year": "Previous year",
"primary-navigation": "Primary navigation",
"profile": "Profile",
"random": "Random",
@@ -152,8 +159,10 @@
"state": "State",
"states": "States",
"states-n": "{n} State | {n} States",
"step-of": "Step {current} of {total}",
"switch-classic-ui": "Switch to classic UI",
"sync": "Sync",
"today": "Today",
"try-again": "Try again",
"type": "Type",
"type-to-confirm": "Type {label} to confirm.",

View File

@@ -45,6 +45,7 @@
"core": "Núcleo",
"create": "Crear",
"crt-mode": "Modo CRT",
"date-picker": "Selector de fecha",
"decade-mix": "Mezcla por décadas",
"decades-n": "{n} década | {n} décadas",
"delete": "Eliminar",
@@ -97,7 +98,10 @@
"music-by-artist": "Bandas sonoras por artista",
"name": "Nombre",
"new-version-available": "Nueva versión disponible",
"next": "Siguiente",
"next-month": "Mes siguiente",
"next-page": "Siguiente",
"next-year": "Año siguiente",
"no-cover": "Sin portada",
"no-results": "Sin resultados",
"not-linked": "Sin vincular",
@@ -115,7 +119,10 @@
"platforms-n": "{n} plataforma | {n} plataformas",
"play-all": "Reproducir todo",
"playlists": "Listas de reproducción",
"previous": "Anterior",
"previous-month": "Mes anterior",
"previous-page": "Anterior",
"previous-year": "Año anterior",
"primary-navigation": "Navegación principal",
"profile": "Perfil",
"random": "Aleatorio",
@@ -152,8 +159,10 @@
"state": "Estado",
"states": "Estados",
"states-n": "{n} Estado | {n} Estados",
"step-of": "Paso {current} de {total}",
"switch-classic-ui": "Cambiar a la interfaz clásica",
"sync": "Sincronizar",
"today": "Hoy",
"try-again": "Reintentar",
"type": "Tipo",
"type-to-confirm": "Escribe {label} para confirmar.",

View File

@@ -45,6 +45,7 @@
"core": "Noyau",
"create": "Créer",
"crt-mode": "Mode CRT",
"date-picker": "Sélecteur de date",
"decade-mix": "Mix par décennie",
"decades-n": "{n} décennie | {n} décennies",
"delete": "Supprimer",
@@ -97,7 +98,10 @@
"music-by-artist": "Bandes-son par artiste",
"name": "Nom",
"new-version-available": "Nouvelle version disponible",
"next": "Suivant",
"next-month": "Mois suivant",
"next-page": "Page suivante",
"next-year": "Année suivante",
"no-cover": "Aucune jaquette",
"no-results": "Aucun résultat",
"not-linked": "Non associé",
@@ -115,7 +119,10 @@
"platforms-n": "{n} plateforme | {n} plateformes",
"play-all": "Tout lire",
"playlists": "Listes de lecture",
"previous": "Précédent",
"previous-month": "Mois précédent",
"previous-page": "Page précédente",
"previous-year": "Année précédente",
"primary-navigation": "Navigation principale",
"profile": "Profil",
"random": "Aléatoire",
@@ -152,8 +159,10 @@
"state": "État",
"states": "États",
"states-n": "{n} État | {n} États",
"step-of": "Étape {current} sur {total}",
"switch-classic-ui": "Basculer vers l'interface classique",
"sync": "Synchroniser",
"today": "Aujourd'hui",
"try-again": "Réessayer",
"type": "Type",
"type-to-confirm": "Tapez {label} pour confirmer.",

View File

@@ -45,6 +45,7 @@
"core": "Mag",
"create": "Létrehoz",
"crt-mode": "CRT mode",
"date-picker": "Dátumválasztó",
"decade-mix": "Évtizedmix",
"decades-n": "{n} évtized | {n} évtized",
"delete": "Törlés",
@@ -97,7 +98,10 @@
"music-by-artist": "Filmzenék előadó szerint",
"name": "Név",
"new-version-available": "Új verzió érhető el",
"next": "Következő",
"next-month": "Következő hónap",
"next-page": "Következő oldal",
"next-year": "Következő év",
"no-cover": "Nincs borító",
"no-results": "Nincs találat",
"not-linked": "Nincs összekötve",
@@ -115,7 +119,10 @@
"platforms-n": "{n} platform | {n} platform",
"play-all": "Összes lejátszása",
"playlists": "Lejátszási listák",
"previous": "Előző",
"previous-month": "Előző hónap",
"previous-page": "Előző oldal",
"previous-year": "Előző év",
"primary-navigation": "Elsődleges navigáció",
"profile": "Profil",
"random": "Véletlenszerű",
@@ -152,8 +159,10 @@
"state": "Állás",
"states": "Állások",
"states-n": "{n} Állás | {n} Állások",
"step-of": "{current}. lépés a {total}-ből",
"switch-classic-ui": "Váltás a klasszikus felületre",
"sync": "Szinkronizálás",
"today": "Ma",
"try-again": "Próbáld újra",
"type": "Típus",
"type-to-confirm": "Írd be: {label} a megerősítéshez.",

View File

@@ -45,6 +45,7 @@
"core": "Core",
"create": "Crea",
"crt-mode": "Modalità CRT",
"date-picker": "Selettore data",
"decade-mix": "Mix per decennio",
"decades-n": "{n} decennio | {n} decenni",
"delete": "Elimina",
@@ -97,7 +98,10 @@
"music-by-artist": "Colonne sonore per artista",
"name": "Nome",
"new-version-available": "Nuova versione disponibile",
"next": "Successivo",
"next-month": "Mese successivo",
"next-page": "Pagina successiva",
"next-year": "Anno successivo",
"no-cover": "Nessuna copertina",
"no-results": "Nessun risultato",
"not-linked": "Non collegato",
@@ -115,7 +119,10 @@
"platforms-n": "{n} piattaforma | {n} piattaforme",
"play-all": "Riproduci tutto",
"playlists": "Playlist",
"previous": "Precedente",
"previous-month": "Mese precedente",
"previous-page": "Pagina precedente",
"previous-year": "Anno precedente",
"primary-navigation": "Navigazione principale",
"profile": "Profilo",
"random": "Casuale",
@@ -152,8 +159,10 @@
"state": "Stato",
"states": "Stati",
"states-n": "{n} Stato | {n} Stati",
"step-of": "Passo {current} di {total}",
"switch-classic-ui": "Passa all'interfaccia classica",
"sync": "Sincronizza",
"today": "Oggi",
"try-again": "Riprova",
"type": "Tipo",
"type-to-confirm": "Digita {label} per confermare.",

View File

@@ -45,6 +45,7 @@
"core": "コア",
"create": "作成",
"crt-mode": "CRT mode",
"date-picker": "日付選択",
"decade-mix": "年代別ミックス",
"decades-n": "{n}年代",
"delete": "削除",
@@ -97,7 +98,10 @@
"music-by-artist": "アーティスト別サウンドトラック",
"name": "名前",
"new-version-available": "新しいバージョンが利用可能です",
"next": "次へ",
"next-month": "翌月",
"next-page": "次のページ",
"next-year": "翌年",
"no-cover": "カバーなし",
"no-results": "結果がありません",
"not-linked": "未連携",
@@ -115,7 +119,10 @@
"platforms-n": "{n}件のプラットフォーム",
"play-all": "すべて再生",
"playlists": "プレイリスト",
"previous": "前へ",
"previous-month": "前月",
"previous-page": "前のページ",
"previous-year": "前年",
"primary-navigation": "メインナビゲーション",
"profile": "プロファイル",
"random": "ランダム",
@@ -152,8 +159,10 @@
"state": "ステートセーブ",
"states": "ステートセーブ",
"states-n": "{n} ステートセーブ | {n} ステートセーブ",
"step-of": "ステップ {current}/{total}",
"switch-classic-ui": "クラシックUIに切り替え",
"sync": "同期",
"today": "今日",
"try-again": "再試行",
"type": "タイプ",
"type-to-confirm": "確認するには{label}と入力してください。",

View File

@@ -45,6 +45,7 @@
"core": "코어",
"create": "생성",
"crt-mode": "CRT mode",
"date-picker": "날짜 선택",
"decade-mix": "연대별 믹스",
"decades-n": "{n}개 연대",
"delete": "삭제",
@@ -97,7 +98,10 @@
"music-by-artist": "아티스트별 사운드트랙",
"name": "이름",
"new-version-available": "새 버전 사용 가능",
"next": "다음",
"next-month": "다음 달",
"next-page": "다음 페이지",
"next-year": "다음 해",
"no-cover": "커버 없음",
"no-results": "결과 없음",
"not-linked": "연결되지 않음",
@@ -115,7 +119,10 @@
"platforms-n": "플랫폼 {n}개",
"play-all": "모두 재생",
"playlists": "재생목록",
"previous": "이전",
"previous-month": "이전 달",
"previous-page": "이전 페이지",
"previous-year": "이전 해",
"primary-navigation": "기본 탐색",
"profile": "프로필",
"random": "무작위",
@@ -152,8 +159,10 @@
"state": "저장 상태",
"states": "저장 상태",
"states-n": "저장 상태 {n}개 | 저장 상태 {n}개",
"step-of": "{total}단계 중 {current}단계",
"switch-classic-ui": "클래식 UI로 전환",
"sync": "동기화",
"today": "오늘",
"try-again": "다시 시도",
"type": "유형",
"type-to-confirm": "확인하려면 {label}을(를) 입력하세요.",

View File

@@ -45,6 +45,7 @@
"core": "Rdzeń",
"create": "Utwórz",
"crt-mode": "CRT mode",
"date-picker": "Wybór daty",
"decade-mix": "Miks dekad",
"decades-n": "{n} dekada | {n} dekady | {n} dekad",
"delete": "Usuń",
@@ -97,7 +98,10 @@
"music-by-artist": "Ścieżki dźwiękowe według wykonawcy",
"name": "Nazwa",
"new-version-available": "Dostępna jest nowa wersja",
"next": "Następny",
"next-month": "Następny miesiąc",
"next-page": "Następna strona",
"next-year": "Następny rok",
"no-cover": "Brak okładki",
"no-results": "Brak wyników",
"not-linked": "Niepowiązane",
@@ -115,7 +119,10 @@
"platforms-n": "{n} platforma | {n} platformy | {n} platform",
"play-all": "Odtwórz wszystko",
"playlists": "Playlisty",
"previous": "Poprzedni",
"previous-month": "Poprzedni miesiąc",
"previous-page": "Poprzednia strona",
"previous-year": "Poprzedni rok",
"primary-navigation": "Nawigacja główna",
"profile": "Profil",
"random": "Losowo",
@@ -152,8 +159,10 @@
"state": "Stan",
"states": "Stany",
"states-n": "{n} Stan | {n} Stany | {n} Stanów",
"step-of": "Krok {current} z {total}",
"switch-classic-ui": "Przełącz na klasyczny interfejs",
"sync": "Synchronizuj",
"today": "Dzisiaj",
"try-again": "Spróbuj ponownie",
"type": "Typ",
"type-to-confirm": "Wpisz {label}, aby potwierdzić.",

View File

@@ -45,6 +45,7 @@
"core": "Núcleo",
"create": "Criar",
"crt-mode": "Modo CRT",
"date-picker": "Seletor de data",
"decade-mix": "Mix por década",
"decades-n": "{n} década | {n} décadas",
"delete": "Excluir",
@@ -97,7 +98,10 @@
"music-by-artist": "Trilhas sonoras por artista",
"name": "Nome",
"new-version-available": "Nova versão disponível",
"next": "Próximo",
"next-month": "Mês seguinte",
"next-page": "Próxima página",
"next-year": "Ano seguinte",
"no-cover": "Sem capa",
"no-results": "Nenhum resultado",
"not-linked": "Não vinculado",
@@ -115,7 +119,10 @@
"platforms-n": "{n} plataforma | {n} plataformas",
"play-all": "Reproduzir tudo",
"playlists": "Listas de reprodução",
"previous": "Anterior",
"previous-month": "Mês anterior",
"previous-page": "Página anterior",
"previous-year": "Ano anterior",
"primary-navigation": "Navegação principal",
"profile": "Perfil",
"random": "Aleatório",
@@ -152,8 +159,10 @@
"state": "Estado",
"states": "Estados",
"states-n": "{n} Estado | {n} Estados",
"step-of": "Etapa {current} de {total}",
"switch-classic-ui": "Mudar para a UI clássica",
"sync": "Sincronizar",
"today": "Hoje",
"try-again": "Tentar novamente",
"type": "Tipo",
"type-to-confirm": "Digite {label} para confirmar.",

View File

@@ -45,6 +45,7 @@
"core": "Nucleu",
"create": "Creează",
"crt-mode": "CRT mode",
"date-picker": "Selector de dată",
"decade-mix": "Mix pe decenii",
"decades-n": "{n} deceniu | {n} decenii",
"delete": "Șterge",
@@ -97,7 +98,10 @@
"music-by-artist": "Coloane sonore după artist",
"name": "Nume",
"new-version-available": "Versiune nouă disponibilă",
"next": "Următorul",
"next-month": "Luna următoare",
"next-page": "Pagina următoare",
"next-year": "Anul următor",
"no-cover": "Fără copertă",
"no-results": "Niciun rezultat",
"not-linked": "Neasociat",
@@ -115,7 +119,10 @@
"platforms-n": "{n} platformă | {n} platforme",
"play-all": "Redă tot",
"playlists": "Liste de redare",
"previous": "Anterior",
"previous-month": "Luna precedentă",
"previous-page": "Pagina anterioară",
"previous-year": "Anul precedent",
"primary-navigation": "Navigare principală",
"profile": "Profil",
"random": "Aleatoriu",
@@ -152,8 +159,10 @@
"state": "Stare",
"states": "Stări",
"states-n": "{n} Stare | {n} Stări",
"step-of": "Pasul {current} din {total}",
"switch-classic-ui": "Treci la interfața clasică",
"sync": "Sincronizează",
"today": "Astăzi",
"try-again": "Încearcă din nou",
"type": "Tip",
"type-to-confirm": "Scrie {label} pentru a confirma.",

View File

@@ -45,6 +45,7 @@
"core": "Ядро",
"create": "Создать",
"crt-mode": "CRT mode",
"date-picker": "Выбор даты",
"decade-mix": "Микс по десятилетиям",
"decades-n": "{n} десятилетие | {n} десятилетия | {n} десятилетий",
"delete": "Удалить",
@@ -97,7 +98,10 @@
"music-by-artist": "Саундтреки по исполнителям",
"name": "Имя",
"new-version-available": "Доступна новая версия",
"next": "Следующий",
"next-month": "Следующий месяц",
"next-page": "Следующая страница",
"next-year": "Следующий год",
"no-cover": "Нет обложки",
"no-results": "Нет результатов",
"not-linked": "Не привязано",
@@ -115,7 +119,10 @@
"platforms-n": "{n} платформа | {n} платформы | {n} платформ",
"play-all": "Воспроизвести всё",
"playlists": "Плейлисты",
"previous": "Предыдущий",
"previous-month": "Предыдущий месяц",
"previous-page": "Предыдущая страница",
"previous-year": "Предыдущий год",
"primary-navigation": "Основная навигация",
"profile": "Профиль",
"random": "Случайный",
@@ -152,8 +159,10 @@
"state": "Состояние",
"states": "Состояния",
"states-n": "{n} Состояние | {n} Состояния",
"step-of": "Шаг {current} из {total}",
"switch-classic-ui": "Переключиться на классический интерфейс",
"sync": "Синхронизировать",
"today": "Сегодня",
"try-again": "Попробовать снова",
"type": "Тип",
"type-to-confirm": "Введите {label} для подтверждения.",

View File

@@ -45,6 +45,7 @@
"core": "Çekirdek",
"create": "Oluştur",
"crt-mode": "CRT modu",
"date-picker": "Tarih seçici",
"decade-mix": "On yıl karması",
"decades-n": "{n} on yıl",
"delete": "Sil",
@@ -97,7 +98,10 @@
"music-by-artist": "Sanatçıya göre oyun müzikleri",
"name": "İsim",
"new-version-available": "Yeni sürüm mevcut",
"next": "Sonraki",
"next-month": "Sonraki ay",
"next-page": "Sonraki sayfa",
"next-year": "Sonraki yıl",
"no-cover": "Kapak yok",
"no-results": "Sonuç yok",
"not-linked": "Bağlı değil",
@@ -115,7 +119,10 @@
"platforms-n": "{n} platform",
"play-all": "Tümünü oynat",
"playlists": "Çalma listeleri",
"previous": "Önceki",
"previous-month": "Önceki ay",
"previous-page": "Önceki sayfa",
"previous-year": "Önceki yıl",
"primary-navigation": "Ana gezinme",
"profile": "Profil",
"random": "Rastgele",
@@ -152,8 +159,10 @@
"state": "Durum kaydı",
"states": "Durum kayıtları",
"states-n": "{n} Durum kaydı | {n} Durum kaydı",
"step-of": "Adım {current}/{total}",
"switch-classic-ui": "Klasik arayüze geç",
"sync": "Senkronize et",
"today": "Bugün",
"try-again": "Tekrar dene",
"type": "Tür",
"type-to-confirm": "Onaylamak için {label} yazın.",

View File

@@ -45,6 +45,7 @@
"core": "核心",
"create": "创建",
"crt-mode": "CRT 模式",
"date-picker": "日期选择器",
"decade-mix": "年代混音",
"decades-n": "{n} 个年代",
"delete": "删除",
@@ -97,7 +98,10 @@
"music-by-artist": "按艺术家浏览原声音乐",
"name": "名称",
"new-version-available": "有新版本可用",
"next": "下一个",
"next-month": "下一个月",
"next-page": "下一页",
"next-year": "下一年",
"no-cover": "无封面",
"no-results": "无结果",
"not-linked": "未关联",
@@ -115,7 +119,10 @@
"platforms-n": "{n} 个平台",
"play-all": "全部播放",
"playlists": "播放列表",
"previous": "上一个",
"previous-month": "上一个月",
"previous-page": "上一页",
"previous-year": "上一年",
"primary-navigation": "主导航",
"profile": "简介",
"random": "随机",
@@ -152,8 +159,10 @@
"state": "状态",
"states": "状态",
"states-n": "{n} 状态 | {n} 状态",
"step-of": "第 {current} 步,共 {total} 步",
"switch-classic-ui": "切换到经典界面",
"sync": "同步",
"today": "今天",
"try-again": "重试",
"type": "类型",
"type-to-confirm": "输入 {label} 以确认。",

View File

@@ -45,6 +45,7 @@
"core": "核心",
"create": "建立",
"crt-mode": "CRT mode",
"date-picker": "日期選擇器",
"decade-mix": "年代混音",
"decades-n": "{n} 個年代",
"delete": "刪除",
@@ -97,7 +98,10 @@
"music-by-artist": "依藝人瀏覽原聲音樂",
"name": "名稱",
"new-version-available": "有新版本可用",
"next": "下一個",
"next-month": "下一個月",
"next-page": "下一頁",
"next-year": "下一年",
"no-cover": "無封面",
"no-results": "沒有結果",
"not-linked": "未連結",
@@ -115,7 +119,10 @@
"platforms-n": "{n} 個平台",
"play-all": "全部播放",
"playlists": "播放清單",
"previous": "上一個",
"previous-month": "上一個月",
"previous-page": "上一頁",
"previous-year": "上一年",
"primary-navigation": "主要導覽",
"profile": "用戶資料",
"random": "隨機",
@@ -152,8 +159,10 @@
"state": "即時存檔",
"states": "即時存檔",
"states-n": "{n} 即時存檔 | {n} 即時存檔",
"step-of": "第 {current} 步,共 {total} 步",
"switch-classic-ui": "切換至經典介面",
"sync": "同步",
"today": "今天",
"try-again": "重試",
"type": "類型",
"type-to-confirm": "請輸入 {label} 以確認。",

View File

@@ -10,7 +10,9 @@ import storeHeartbeat from "@/stores/heartbeat";
import "@/styles/common.css";
import "@/styles/fonts.css";
import "@/styles/scrollbar.css";
import { ChromeLabelsKey } from "@/v2/lib/a11y/chromeLabels";
import "@/v2/styles/global.css";
import { createChromeLabels } from "@/v2/utils/chromeLabels";
// Recover from stale chunks after a redeploy: hashed asset names change, so
// a tab opened before the deploy 404s (or gets HTML) on its next lazy import
@@ -62,6 +64,10 @@ async function initializeApp() {
// Registrar vuetify + pinia + i18n + emitter
registerPlugins(app);
// Accessible names the v2 primitives render for their own controls.
// Provided once, after i18n is registered.
app.provide(ChromeLabelsKey, createChromeLabels());
// Locale messages gate the router alongside the initial data: the guard
// resolves the route title as soon as the router is installed, and with
// messages still in flight it would set the raw key as the tab title.

View File

@@ -0,0 +1,97 @@
import { RAlert, RChip, RSteps } from "@v2/lib";
import { mount } from "@vue/test-utils";
import { describe, expect, it } from "vitest";
import {
ChromeLabelsKey,
DEFAULT_CHROME_LABELS,
useChromeLabels,
type ChromeLabels,
} from "./chromeLabels";
const Consumer = {
setup() {
return { labels: useChromeLabels() };
},
template: `<i>{{ labels.close }}</i>`,
};
function bundle(overrides: Partial<ChromeLabels> = {}): ChromeLabels {
return { ...DEFAULT_CHROME_LABELS, ...overrides };
}
describe("useChromeLabels", () => {
it("falls back to English when nothing is provided", () => {
const wrapper = mount(Consumer);
expect(wrapper.text()).toBe("Close");
wrapper.unmount();
});
it("reads the injected bundle", () => {
const wrapper = mount(Consumer, {
global: {
provide: {
[ChromeLabelsKey as symbol]: bundle({ close: "Schließen" }),
},
},
});
expect(wrapper.text()).toBe("Schließen");
wrapper.unmount();
});
});
describe("primitives consume the injected bundle", () => {
it("RChip's remove button uses the injected label", () => {
const wrapper = mount(RChip, {
props: { closable: true },
global: {
provide: {
[ChromeLabelsKey as symbol]: bundle({ remove: "Entfernen" }),
},
},
});
expect(wrapper.get("button.r-chip__close").attributes("aria-label")).toBe(
"Entfernen",
);
wrapper.unmount();
});
it("RAlert's close button uses the injected label", () => {
const wrapper = mount(RAlert, {
props: { closable: true },
global: {
provide: {
[ChromeLabelsKey as symbol]: bundle({ close: "Schließen" }),
},
},
});
expect(wrapper.get("button.r-alert__close").attributes("aria-label")).toBe(
"Schließen",
);
wrapper.unmount();
});
it("RSteps builds its stepper name from the injected formatter", () => {
const wrapper = mount(RSteps, {
props: { total: 3, current: 2 },
global: {
provide: {
[ChromeLabelsKey as symbol]: bundle({
step: (current, total) => `Schritt ${current} von ${total}`,
}),
},
},
});
expect(wrapper.get("ol.r-steps").attributes("aria-label")).toBe(
"Schritt 2 von 3",
);
wrapper.unmount();
});
it("RChip falls back to English with no provider", () => {
const wrapper = mount(RChip, { props: { closable: true } });
expect(wrapper.get("button.r-chip__close").attributes("aria-label")).toBe(
"Remove",
);
wrapper.unmount();
});
});

View File

@@ -0,0 +1,58 @@
// Accessible names for controls a primitive renders on its own behalf: a
// dialog's close button, a chip's remove X, a date field's steppers. Not
// caller-supplied content, and a per-instance prop for each would have to be
// passed at every call site to do anything (the `closeLabel` / `clearLabel`
// props that predate this never were, so they rendered English everywhere).
//
// So the app provides one bundle of i18n-backed getters, read during the
// consuming component's render so a locale switch propagates. `inject` is
// plain Vue, keeping the library free of i18n; unprovided, English applies.
import { inject } from "vue";
import type { InjectionKey } from "vue";
export interface ChromeLabels {
/** Dismiss affordance on dialogs, drawers and the carousel. */
close: string;
/** Reset affordance on text, select and combobox fields. */
clear: string;
/** Per-item removal on chips and multi-select values. */
remove: string;
/** Select-all entry in a multi-select's option list. */
all: string;
/** Carousel step controls. */
previous: string;
next: string;
/** Date field: the picker toggle, its steppers and the today shortcut. */
datePicker: string;
previousYear: string;
previousMonth: string;
nextMonth: string;
nextYear: string;
today: string;
/** Accessible name for a stepper, e.g. "Step 2 of 5". */
step: (current: number, total: number) => string;
}
export const DEFAULT_CHROME_LABELS: ChromeLabels = {
close: "Close",
clear: "Clear",
remove: "Remove",
all: "All",
previous: "Previous",
next: "Next",
datePicker: "Date picker",
previousYear: "Previous year",
previousMonth: "Previous month",
nextMonth: "Next month",
nextYear: "Next year",
today: "Today",
step: (current, total) => `Step ${current} of ${total}`,
};
export const ChromeLabelsKey: InjectionKey<ChromeLabels> =
Symbol("RChromeLabels");
/** Read the injected bundle, falling back to English. */
export function useChromeLabels(): ChromeLabels {
return inject(ChromeLabelsKey, DEFAULT_CHROME_LABELS);
}

View File

@@ -37,6 +37,7 @@ import {
useSlots,
watch,
} from "vue";
import { useChromeLabels } from "@/v2/lib/a11y/chromeLabels";
import RIcon from "@/v2/lib/primitives/RIcon/RIcon.vue";
import RTag from "@/v2/lib/primitives/RTag/RTag.vue";
@@ -85,6 +86,8 @@ const props = withDefaults(defineProps<Props>(), {
clearable: false,
});
const labels = useChromeLabels();
const emit = defineEmits<{
(e: "update:modelValue", value: string[]): void;
}>();
@@ -360,7 +363,7 @@ const showDetails = computed(
type="button"
class="r-combobox-field__chip-close"
tabindex="-1"
aria-label="Remove"
:aria-label="labels.remove"
@mousedown.prevent
@click.stop="removeAt(i)"
>
@@ -394,7 +397,7 @@ const showDetails = computed(
type="button"
class="r-combobox-field__clear"
tabindex="-1"
aria-label="Clear"
:aria-label="labels.clear"
@mousedown.prevent
@click.stop="clearAll"
>

View File

@@ -111,4 +111,30 @@ describe("RDateField", () => {
await wrapper.setProps({ modelValue: picked });
expect(wrapper.get("input").element.value).toBe("Mar 1, 2024");
});
// ARIA 1.2 puts the combobox role on the focusable element.
it("wires the combobox role onto the input, not the wrapper", async () => {
const wrapper = mount(RDateField, {
props: { modelValue: Date.UTC(2024, 2, 15) },
attachTo: document.body,
});
const input = wrapper.get("input");
expect(input.attributes("role")).toBe("combobox");
expect(input.attributes("aria-haspopup")).toBe("dialog");
expect(input.attributes("aria-expanded")).toBe("false");
expect(wrapper.get(".r-date-field").attributes("role")).toBeUndefined();
// Closed, the panel is unmounted, so nothing may point at it.
expect(input.attributes("aria-controls")).toBeUndefined();
await input.trigger("click");
await wrapper.vm.$nextTick();
expect(input.attributes("aria-expanded")).toBe("true");
const panelId = input.attributes("aria-controls");
expect(panelId).toBeTruthy();
expect(document.getElementById(panelId as string)).toHaveProperty(
"role",
"dialog",
);
});
});

View File

@@ -29,8 +29,10 @@ import {
onBeforeUnmount,
onMounted,
ref,
useId,
watch,
} from "vue";
import { useChromeLabels } from "@/v2/lib/a11y/chromeLabels";
import RBtn from "../../primitives/RBtn/RBtn.vue";
import RIcon from "../../primitives/RIcon/RIcon.vue";
import RTextField from "../RTextField/RTextField.vue";
@@ -71,18 +73,26 @@ const props = withDefaults(defineProps<Props>(), {
firstDayOfWeek: 1,
min: null,
max: null,
todayLabel: "Today",
clearLabel: "Clear",
hideFooter: false,
disabled: false,
displayFormat: () => ({ dateStyle: "medium" }),
todayLabel: undefined,
clearLabel: undefined,
clearable: false,
});
const labels = useChromeLabels();
const todayText = computed(() => props.todayLabel ?? labels.today);
const clearText = computed(() => props.clearLabel ?? labels.clear);
const emit = defineEmits<{
(e: "update:modelValue", value: Date | null): void;
}>();
// Referenced by the input's aria-controls.
const panelId = useId();
// ── Value normalization ────────────────────────────────────────
function toDate(v: Date | number | string | null | undefined): Date | null {
if (v == null || v === "") return null;
@@ -441,18 +451,10 @@ onBeforeUnmount(() => {
</script>
<template>
<!-- combobox role goes here, not on RTextField: with a visible label
RTextField renders a <label>, where the role is disallowed and voids
the input's label association. -->
<!-- Keydown sits here so Escape and the arrows work wherever focus is
inside the field; the combobox role goes on the input via `popup`. -->
<!-- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -->
<div
ref="referenceEl"
class="r-date-field"
role="combobox"
aria-haspopup="dialog"
:aria-expanded="isOpen"
@keydown="onFieldKeydown"
>
<div ref="referenceEl" class="r-date-field" @keydown="onFieldKeydown">
<!-- Single `@click` on the wrapper is enough: native clicks on
every part of the field (input, icon, label well) bubble up
here. We deliberately don't subscribe to `click:append-inner` —
@@ -462,6 +464,11 @@ onBeforeUnmount(() => {
:model-value="displayValue"
:disabled="disabled"
:focused="isOpen"
:popup="{
controls: isOpen ? panelId : undefined,
expanded: isOpen,
kind: 'dialog',
}"
readonly
:append-inner-icon="
clearable && selectedDate ? undefined : 'mdi-calendar'
@@ -475,7 +482,7 @@ onBeforeUnmount(() => {
<button
type="button"
class="r-date-field__clear"
:aria-label="clearLabel"
:aria-label="clearText"
@mousedown.prevent
@click.stop="clearValue"
>
@@ -489,11 +496,12 @@ onBeforeUnmount(() => {
<!-- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -->
<div
v-if="isOpen"
:id="panelId"
ref="panelRef"
class="r-date-cal"
:style="floatingStyles"
role="dialog"
aria-label="Date picker"
:aria-label="labels.datePicker"
@keydown="onPanelKeydown"
>
<!-- Header — month/year title flanked by nav arrows. The
@@ -503,7 +511,7 @@ onBeforeUnmount(() => {
<button
type="button"
class="r-date-cal__nav"
aria-label="Previous year"
:aria-label="labels.previousYear"
@click="shiftYear(-1)"
>
<RIcon icon="mdi-chevron-double-left" size="x-small" />
@@ -511,7 +519,7 @@ onBeforeUnmount(() => {
<button
type="button"
class="r-date-cal__nav"
aria-label="Previous month"
:aria-label="labels.previousMonth"
@click="shiftMonth(-1)"
>
<RIcon icon="mdi-chevron-left" size="x-small" />
@@ -524,7 +532,7 @@ onBeforeUnmount(() => {
<button
type="button"
class="r-date-cal__nav"
aria-label="Next month"
:aria-label="labels.nextMonth"
@click="shiftMonth(1)"
>
<RIcon icon="mdi-chevron-right" size="x-small" />
@@ -532,7 +540,7 @@ onBeforeUnmount(() => {
<button
type="button"
class="r-date-cal__nav"
aria-label="Next year"
:aria-label="labels.nextYear"
@click="shiftYear(1)"
>
<RIcon icon="mdi-chevron-double-right" size="x-small" />
@@ -582,7 +590,7 @@ onBeforeUnmount(() => {
quick-access buttons (e.g. embedded in a complex form). -->
<div v-if="!hideFooter" class="r-date-cal__foot">
<RBtn variant="text" size="small" @click="selectToday">
{{ todayLabel }}
{{ todayText }}
</RBtn>
<RBtn
variant="text"
@@ -591,7 +599,7 @@ onBeforeUnmount(() => {
:disabled="!selectedDate"
@click="clearValue"
>
{{ clearLabel }}
{{ clearText }}
</RBtn>
</div>
</div>

View File

@@ -37,6 +37,7 @@ import {
watch,
} from "vue";
import { useInputModality } from "@/v2/composables/useInputModality";
import { useChromeLabels } from "@/v2/lib/a11y/chromeLabels";
import { shouldAutofocusSearch } from "@/v2/utils/autofocus";
import RDivider from "../../primitives/RDivider/RDivider.vue";
import RIcon from "../../primitives/RIcon/RIcon.vue";
@@ -151,6 +152,7 @@ const props = withDefaults(defineProps<Props>(), {
density: "comfortable",
itemTitle: "title",
itemValue: "value",
allOptionLabel: undefined,
multiple: false,
returnObject: false,
chips: false,
@@ -177,11 +179,14 @@ const props = withDefaults(defineProps<Props>(), {
maxVisibleChips: Number.POSITIVE_INFINITY,
chipTone: "brand",
showAllOption: false,
allOptionLabel: "All",
dividerAfter: undefined,
info: undefined,
});
const labels = useChromeLabels();
const allText = computed(() => props.allOptionLabel ?? labels.all);
const emit = defineEmits<{
(e: "update:modelValue", value: unknown): void;
(e: "update:search", value: string): void;
@@ -1009,13 +1014,13 @@ const describedBy = computed(() => {
:tone="chipTone"
size="small"
>
{{ allOptionLabel }}
{{ allText }}
<template v-if="closableChips" #append>
<button
type="button"
class="r-select__chip-close"
tabindex="-1"
aria-label="Remove"
:aria-label="labels.remove"
@mousedown.prevent
@click.stop="isAllSelected = false"
>
@@ -1052,7 +1057,7 @@ const describedBy = computed(() => {
type="button"
class="r-select__chip-close"
tabindex="-1"
aria-label="Remove"
:aria-label="labels.remove"
@mousedown.prevent
@click.stop="removeSelection(item.value)"
>
@@ -1109,7 +1114,7 @@ const describedBy = computed(() => {
type="button"
class="r-select__clear"
tabindex="-1"
aria-label="Clear"
:aria-label="labels.clear"
@mousedown.prevent
@click.stop="clear"
>
@@ -1216,7 +1221,7 @@ const describedBy = computed(() => {
@click="toggleAllItems"
@mouseenter="activeIndex = -1"
>
<span class="r-select__item-title">{{ allOptionLabel }}</span>
<span class="r-select__item-title">{{ allText }}</span>
<RIcon
v-if="isAllSelected"
icon="mdi-check"

View File

@@ -0,0 +1,54 @@
import { mount } from "@vue/test-utils";
import { afterEach, describe, expect, it, vi } from "vitest";
import RTextField from "./RTextField.vue";
const POPUP = {
controls: "popup-1",
expanded: false,
kind: "dialog",
} as const;
afterEach(() => {
vi.restoreAllMocks();
});
describe("RTextField popup wiring", () => {
it("puts the combobox role on the input, not the outer element", () => {
const wrapper = mount(RTextField, {
props: {
modelValue: "",
prefixLabel: "stacked",
label: "When",
popup: POPUP,
},
});
const input = wrapper.get("input");
expect(input.attributes("role")).toBe("combobox");
expect(input.attributes("aria-haspopup")).toBe("dialog");
expect(input.attributes("aria-controls")).toBe("popup-1");
// The outer element is a <label> here, where the role is disallowed.
const outer = wrapper.get("label.r-text-field");
expect(outer.attributes("role")).toBeUndefined();
wrapper.unmount();
});
it("carries no combobox attributes without the prop", () => {
const wrapper = mount(RTextField, { props: { modelValue: "" } });
expect(wrapper.get("input").attributes("role")).toBeUndefined();
wrapper.unmount();
});
it("reports the conflict rather than dropping the ARIA silently", () => {
const error = vi.spyOn(console, "error").mockImplementation(() => {});
const wrapper = mount(RTextField, {
props: { modelValue: "", multiline: true, popup: POPUP },
});
expect(wrapper.find("textarea").exists()).toBe(true);
expect(error).toHaveBeenCalledWith(
expect.stringContaining("`popup` is ignored when `multiline` is set"),
);
wrapper.unmount();
});
});

View File

@@ -27,7 +27,9 @@ import {
useAttrs,
useSlots,
watch,
watchEffect,
} from "vue";
import { useChromeLabels } from "@/v2/lib/a11y/chromeLabels";
import RIcon from "../../primitives/RIcon/RIcon.vue";
import RProgressCircular from "../../primitives/RProgressCircular/RProgressCircular.vue";
import RTooltip from "../../structural/RTooltip/RTooltip.vue";
@@ -106,6 +108,17 @@ interface Props {
* pairs with the field's value. The `#subtitle` slot wins over the
* prop when both are provided; use the slot to drop in an icon. */
subtitle?: string;
/** Wires the native input as a combobox owning a popup, putting the role
* on the input rather than the outer element (a `<label>` when this field
* owns its visible label). Single-line only: `role="combobox"` is not
* valid on a `<textarea>`. */
popup?: {
/** `id` of the popup element. Omit while it is unmounted, so
* `aria-controls` never points at an element that is not there. */
controls?: string;
expanded: boolean;
kind: "dialog" | "listbox" | "grid";
};
}
const props = withDefaults(defineProps<Props>(), {
@@ -142,6 +155,17 @@ const props = withDefaults(defineProps<Props>(), {
rows: 4,
mono: false,
subtitle: undefined,
popup: undefined,
});
const labels = useChromeLabels();
watchEffect(() => {
if (props.multiline && props.popup) {
console.error(
"[RTextField] `popup` is ignored when `multiline` is set: role=combobox is not valid on a <textarea>.",
);
}
});
const emit = defineEmits<{
@@ -160,9 +184,8 @@ const emit = defineEmits<{
const slots = useSlots();
const attrs = useAttrs();
const inputRef = ref<HTMLInputElement | HTMLTextAreaElement | null>(null);
// Stable id for `aria-describedby` — Vue 3.5 ships `useId`, but we're
// on 3.4 still. The instance uid is unique per mounted component, which
// is plenty for aria wiring.
// Stable id for `aria-describedby`. The instance uid is unique per mounted
// component, which is plenty for aria wiring.
const fieldId = `r-tf-${getCurrentInstance()?.uid ?? Math.random().toString(36).slice(2)}`;
// ── Tone resolver — same vocabulary as the rest of the lib ─────
@@ -506,6 +529,10 @@ function onAppendInnerClick(evt: MouseEvent) {
:aria-label="effectiveAriaLabel"
:aria-invalid="hasError || undefined"
:aria-describedby="showDetails ? `${fieldId}-details` : undefined"
:role="popup ? 'combobox' : undefined"
:aria-haspopup="popup?.kind"
:aria-expanded="popup ? popup.expanded : undefined"
:aria-controls="popup?.controls"
@input="onInput"
@focus="onFocus"
@blur="onBlur"
@@ -550,7 +577,7 @@ function onAppendInnerClick(evt: MouseEvent) {
type="button"
class="r-text-field__clear"
tabindex="-1"
aria-label="Clear"
:aria-label="labels.clear"
@mousedown.prevent
@click.stop="clear"
>

View File

@@ -30,6 +30,7 @@ import {
ref,
watch,
} from "vue";
import { useChromeLabels } from "@/v2/lib/a11y/chromeLabels";
import RBtn from "@/v2/lib/primitives/RBtn/RBtn.vue";
import RIcon from "@/v2/lib/primitives/RIcon/RIcon.vue";
import type { RCarouselProps } from "./types";
@@ -42,12 +43,18 @@ const props = withDefaults(defineProps<RCarouselProps<T>>(), {
showCounter: undefined,
showArrows: undefined,
showThumbnails: false,
closeLabel: "Close",
prevLabel: "Previous",
nextLabel: "Next",
closeLabel: undefined,
prevLabel: undefined,
nextLabel: undefined,
ariaLabel: undefined,
});
const labels = useChromeLabels();
const closeText = computed(() => props.closeLabel ?? labels.close);
const prevText = computed(() => props.prevLabel ?? labels.previous);
const nextText = computed(() => props.nextLabel ?? labels.next);
const emit = defineEmits<{
(e: "update:modelValue", value: number): void;
(e: "prev"): void;
@@ -212,7 +219,7 @@ function onBackdropClick(event: MouseEvent) {
<button
type="button"
class="r-carousel__close"
:aria-label="closeLabel"
:aria-label="closeText"
@click="close"
>
<RIcon icon="mdi-close" size="20" />
@@ -248,7 +255,7 @@ function onBackdropClick(event: MouseEvent) {
v-if="showArrowsResolved"
type="button"
class="r-carousel__nav r-carousel__nav--prev"
:aria-label="prevLabel"
:aria-label="prevText"
:disabled="!loop && safeIndex === 0"
@click.stop="go(-1)"
>
@@ -258,7 +265,7 @@ function onBackdropClick(event: MouseEvent) {
v-if="showArrowsResolved"
type="button"
class="r-carousel__nav r-carousel__nav--next"
:aria-label="nextLabel"
:aria-label="nextText"
:disabled="!loop && safeIndex === total - 1"
@click.stop="go(1)"
>
@@ -332,7 +339,7 @@ function onBackdropClick(event: MouseEvent) {
variant="translucent"
size="small"
class="r-carousel__nav r-carousel__nav--prev"
:aria-label="prevLabel"
:aria-label="prevText"
:disabled="!loop && safeIndex === 0"
@click.stop="go(-1)"
/>
@@ -342,7 +349,7 @@ function onBackdropClick(event: MouseEvent) {
variant="translucent"
size="small"
class="r-carousel__nav r-carousel__nav--next"
:aria-label="nextLabel"
:aria-label="nextText"
:disabled="!loop && safeIndex === total - 1"
@click.stop="go(1)"
/>

View File

@@ -16,6 +16,7 @@
// belong inside the consumer's `#content` slot — composed from
// REmptyState / RProgressCircular / RSpinner as needed.
import { computed, nextTick, onBeforeUnmount, ref, useSlots, watch } from "vue";
import { useChromeLabels } from "@/v2/lib/a11y/chromeLabels";
import RIcon from "@/v2/lib/primitives/RIcon/RIcon.vue";
import { createBodyScrollLock, overlayCount } from "../bodyScrollLock";
import {
@@ -69,6 +70,8 @@ const emit = defineEmits<{
const slots = useSlots();
const labels = useChromeLabels();
const panelRef = ref<HTMLElement | null>(null);
// Element that had focus before the dialog opened — focus returns here
// when the dialog closes so keyboard users don't lose their place.
@@ -235,7 +238,7 @@ const panelStyle = computed(() => {
<button
type="button"
class="r-dialog__close"
aria-label="Close"
:aria-label="labels.close"
@click="closeDialog"
>
<RIcon icon="mdi-close" size="16" />

View File

@@ -18,6 +18,7 @@
// firmware drawers when they get migrated), context-driven settings
// flyouts, etc.
import { computed, nextTick, onBeforeUnmount, ref, useSlots, watch } from "vue";
import { useChromeLabels } from "@/v2/lib/a11y/chromeLabels";
import RIcon from "@/v2/lib/primitives/RIcon/RIcon.vue";
import {
type EscapableEntry,
@@ -63,6 +64,8 @@ const emit = defineEmits<{
const slots = useSlots();
const labels = useChromeLabels();
const panelRef = ref<HTMLElement | null>(null);
// Element that had focus before the drawer opened — focus returns here
// when the drawer closes so keyboard users don't lose their place.
@@ -187,7 +190,7 @@ const transitionName = computed(() =>
v-if="!hideClose"
type="button"
class="r-drawer__close"
aria-label="Close"
:aria-label="labels.close"
@click="closeDrawer"
>
<RIcon icon="mdi-close" size="16" />

View File

@@ -22,6 +22,7 @@
// X emits `click:close` and flips `modelValue` to false; the leave
// transition runs before the DOM is removed.
import { computed, useSlots } from "vue";
import { useChromeLabels } from "@/v2/lib/a11y/chromeLabels";
import RIcon from "../RIcon/RIcon.vue";
defineOptions({ inheritAttrs: false });
@@ -42,6 +43,8 @@ interface Props {
modelValue?: boolean;
}
const labels = useChromeLabels();
const props = withDefaults(defineProps<Props>(), {
type: undefined,
variant: "translucent",
@@ -172,7 +175,7 @@ function close(evt: MouseEvent) {
v-if="closable"
type="button"
class="r-alert__close"
:aria-label="'Close'"
:aria-label="labels.close"
@click="close"
>
<RIcon icon="mdi-close" class="r-alert__close-icon" />

View File

@@ -17,6 +17,7 @@
// in lists). `rounded` overrides the default pill / label radius if
// you need a specific radius.
import { computed } from "vue";
import { useChromeLabels } from "@/v2/lib/a11y/chromeLabels";
import RIcon from "../RIcon/RIcon.vue";
defineOptions({ inheritAttrs: false });
@@ -54,6 +55,8 @@ const emit = defineEmits<{
(e: "click:close", evt: MouseEvent): void;
}>();
const labels = useChromeLabels();
const TONE_MAP: Record<string, string> = {
primary: "var(--r-color-brand-primary)",
secondary: "var(--r-color-brand-secondary)",
@@ -141,7 +144,7 @@ function onClose(evt: MouseEvent) {
v-if="closable"
type="button"
class="r-chip__close"
aria-label="Remove"
:aria-label="labels.remove"
:disabled="disabled"
@click="onClose"
>

View File

@@ -14,6 +14,7 @@
// scaleX from a left origin, so growing reads as forward and shrinking
// reads as the right edge emptying first (which feels like reverse).
import { computed, ref, watch } from "vue";
import { useChromeLabels } from "@/v2/lib/a11y/chromeLabels";
defineOptions({ inheritAttrs: false });
@@ -36,6 +37,8 @@ interface Props {
dotSize?: number;
}
const labels = useChromeLabels();
const props = withDefaults(defineProps<Props>(), {
steps: undefined,
total: undefined,
@@ -82,7 +85,7 @@ watch(
<template>
<ol
class="r-steps"
:aria-label="`Step ${current} of ${items.length}`"
:aria-label="labels.step(current, items.length)"
:data-direction="direction"
>
<template v-for="(item, i) in items" :key="item.index">

View File

@@ -0,0 +1,98 @@
import { mount } from "@vue/test-utils";
import { readdirSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { afterEach, beforeAll, describe, expect, it } from "vitest";
import i18n, { loadLocale } from "@/locales";
import {
ChromeLabelsKey,
DEFAULT_CHROME_LABELS,
useChromeLabels,
} from "@/v2/lib/a11y/chromeLabels";
import { createChromeLabels } from "./chromeLabels";
// Catches a label pointing at a key no locale defines, and the provider
// coming unwired. A key missing from one locale falls back to en_US rather
// than to the key, so that case stays the parity checker's job.
const STRING_KEYS = (
Object.keys(DEFAULT_CHROME_LABELS) as (keyof typeof DEFAULT_CHROME_LABELS)[]
).filter((key) => typeof DEFAULT_CHROME_LABELS[key] === "string");
const LOCALES_DIR = join(
dirname(fileURLToPath(import.meta.url)),
"../../locales",
);
const locales = readdirSync(LOCALES_DIR, { withFileTypes: true })
.filter((entry) => entry.isDirectory() && entry.name !== "__pycache__")
.map((entry) => entry.name);
beforeAll(async () => {
await Promise.all(locales.map((locale) => loadLocale(locale)));
});
afterEach(() => {
i18n.global.locale.value = "en_US";
});
describe("createChromeLabels", () => {
it("covers every string label in the contract", () => {
expect(STRING_KEYS.length).toBe(
Object.keys(DEFAULT_CHROME_LABELS).length - 1,
);
});
describe.each(locales)("%s", (locale) => {
it.each(STRING_KEYS)("resolves %s", (key) => {
i18n.global.locale.value = locale;
const value = createChromeLabels()[key] as string;
expect(value, key).toBeTruthy();
// An unresolved key comes back as the key itself.
expect(value, key).not.toMatch(/^common\./);
expect(value.trim(), key).toBe(value);
});
it("interpolates the stepper label", () => {
i18n.global.locale.value = locale;
const value = createChromeLabels().step(2, 5);
expect(value).not.toMatch(/^common\./);
expect(value).toContain("2");
expect(value).toContain("5");
expect(value).not.toContain("{");
});
});
it("differs from English in a translated locale", () => {
i18n.global.locale.value = "de_DE";
const german = createChromeLabels().close;
i18n.global.locale.value = "en_US";
expect(german).not.toBe(createChromeLabels().close);
});
});
// The point of getters over a snapshot: an already-mounted primitive picks
// up a locale switch on its own, with no forced re-render.
describe("a live locale switch reaches a mounted component", () => {
const Consumer = {
setup() {
return { labels: useChromeLabels() };
},
template: `<i>{{ labels.close }}</i>`,
};
it("re-renders the label when i18n.global.locale changes", async () => {
i18n.global.locale.value = "en_US";
const wrapper = mount(Consumer, {
global: {
provide: { [ChromeLabelsKey as symbol]: createChromeLabels() },
},
});
expect(wrapper.text()).toBe("Close");
i18n.global.locale.value = "de_DE";
await wrapper.vm.$nextTick();
expect(wrapper.text()).toBe("Schließen");
wrapper.unmount();
});
});

View File

@@ -0,0 +1,54 @@
// Translated backing for the v2 library's chrome labels (see
// `@/v2/lib/a11y/chromeLabels`). Primitives may not touch i18n, so the app
// builds the bundle here and provides it once.
//
// Each property is a getter, so `t` runs inside the reading component's
// render effect and a locale switch re-renders the labels. Utility code is
// allowed to call i18n.global directly, as `validation.ts` does.
import i18n from "@/locales";
import type { ChromeLabels } from "@/v2/lib/a11y/chromeLabels";
const t = (key: string) => i18n.global.t(key);
export function createChromeLabels(): ChromeLabels {
return {
get close() {
return t("common.close");
},
get clear() {
return t("common.clear");
},
get remove() {
return t("common.remove");
},
get all() {
return t("common.all");
},
get previous() {
return t("common.previous");
},
get next() {
return t("common.next");
},
get datePicker() {
return t("common.date-picker");
},
get previousYear() {
return t("common.previous-year");
},
get previousMonth() {
return t("common.previous-month");
},
get nextMonth() {
return t("common.next-month");
},
get nextYear() {
return t("common.next-year");
},
get today() {
return t("common.today");
},
step: (current, total) =>
i18n.global.t("common.step-of", { current, total }),
};
}