From ffd26fe6dcca8b1a1b209ff56970f9e7abfd39d9 Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Fri, 18 Sep 2026 10:19:33 -0500 Subject: [PATCH] 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 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 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 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