fix(v2): work down the a11y backlog surfaced by the axe gate

Resolve 7 of the 8 ratcheted `todo` stories with real fixes and flip them
back to the `error` gate:

- RProgressCircular: add optional `label`; render aria-hidden when the ring
  is decorative (indeterminate + no label/slot), else name it via label or
  slot content. Cascades to RSpinner, RSelect (Loading), RTextField (Loading).
- RTextField: label the interactive prepend/append-inner adornment button
  from a new `*InnerLabel` prop (falls back to the tooltip).
- RDateField: move role="combobox" off the RTextField `<label>` wrapper onto
  the field container, restoring the input's label and using an allowed role.
- RTable: mark the layout-only scroll/body containers presentational so
  rows/cells resolve their required table parent in all states.
- RMenuItem, RDropzone, RSlider: supply the menu parent / input label /
  slider aria-label the components already support.

RSelect (Clearable) stays `todo`: the clear button is nested inside the
activator button and the correct fix is a visual-layout refactor that needs
in-browser verification.

Refs #1848

Generated-By: PostHog Code
Task-Id: b44aba2c-90c9-407d-8c80-5bbe77ecd6c1
This commit is contained in:
Georges-Antoine Assi
2026-07-05 22:30:19 -04:00
parent 1eb4d1c8ed
commit 240127ee88
13 changed files with 107 additions and 60 deletions

View File

@@ -11,9 +11,6 @@ const meta: Meta = {
// RTable is generic, so its component-typed shape doesn't fit
// Storybook's `component` slot. The cast is narrow + intentional.
component: RTable as never,
// a11y todo (#1848): grid roles need their required parent structure so
// rows/cells are announced correctly (incl. the mobile card-stack mode).
parameters: { a11y: { test: "todo" } },
argTypes: {
loading: { control: "boolean" },
sortKey: { control: "text" },

View File

@@ -143,6 +143,7 @@ onBeforeUnmount(() => {
<div
class="r-table"
:class="{ 'r-table--mobile-stack': mobileStack }"
role="table"
v-bind="$attrs"
>
<!-- Header row — each column header is a cell `<div>` containing
@@ -151,7 +152,11 @@ onBeforeUnmount(() => {
icon next to "Type"). The sort button is the only interactive
element so adornments stay focusable / clickable on their own
without nesting buttons. -->
<div class="r-table__scroll" :style="scrollStyle">
<!-- scroll + body are layout-only containers; mark them presentational
so rows sit directly under the role="table" root and satisfy the
row/columnheader/cell parent requirements across the loading,
empty, and populated states (the header row is always present). -->
<div class="r-table__scroll" :style="scrollStyle" role="presentation">
<div class="r-table__header" :style="gridStyle" role="row">
<div
v-for="col in columns"
@@ -198,7 +203,7 @@ onBeforeUnmount(() => {
</div>
<!-- Body — skeletons / real rows / empty state, in that order. -->
<div class="r-table__body">
<div class="r-table__body" role="presentation">
<template v-if="loading">
<div
v-for="i in loadingRows"

View File

@@ -5,9 +5,6 @@ import RDateField from "./RDateField.vue";
const meta: Meta<typeof RDateField> = {
title: "Forms/RDateField",
component: RDateField,
// a11y todo (#1848): calendar grid cells use an unsupported role and the
// field input lacks a programmatic label. Needs a component-level fix.
parameters: { a11y: { test: "todo" } },
argTypes: {
firstDayOfWeek: {
control: "inline-radio",

View File

@@ -410,8 +410,19 @@ onBeforeUnmount(() => {
</script>
<template>
<!-- The combobox role lives on this wrapper (a real element that owns
the textbox), not on RTextField: when a visible label is present
RTextField renders a `<label>`, and a role there both voids the
implicit label association and is a disallowed role. -->
<!-- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -->
<div ref="referenceEl" class="r-date-field" @keydown="onFieldKeydown">
<div
ref="referenceEl"
class="r-date-field"
role="combobox"
aria-haspopup="dialog"
:aria-expanded="isOpen"
@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` —
@@ -425,9 +436,6 @@ onBeforeUnmount(() => {
:append-inner-icon="
clearable && selectedDate ? undefined : 'mdi-calendar'
"
:aria-haspopup="'dialog'"
:aria-expanded="isOpen"
role="combobox"
@click="toggle"
>
<template v-if="clearable && selectedDate" #append-inner>

View File

@@ -6,9 +6,6 @@ import RDropzone from "./RDropzone.vue";
const meta: Meta<typeof RDropzone> = {
title: "Forms/RDropzone",
component: RDropzone,
// a11y todo (#1848): the hidden file input needs a programmatic label
// tied to the visible drop-zone copy.
parameters: { a11y: { test: "todo" } },
argTypes: {
title: { control: "text" },
hint: { control: "text" },
@@ -25,6 +22,7 @@ const meta: Meta<typeof RDropzone> = {
title: "Drop files here",
hint: "Drag and drop, or click to browse",
activeTitle: "Release to upload",
inputLabel: "Upload files",
multiple: true,
},
render: (args) => ({

View File

@@ -177,8 +177,6 @@ export const Disabled: Story = {
};
export const Loading: Story = {
// a11y todo (#1848): loading spinner (role="progressbar") needs a name.
parameters: { a11y: { test: "todo" } },
args: { placeholder: "Loading platforms…", loading: true },
};
@@ -213,8 +211,12 @@ export const Validation: Story = {
// ── Clearable ──────────────────────────────────────────────────────
export const Clearable: Story = {
// a11y todo (#1848): the clear affordance nests an interactive control
// inside the combobox; needs restructuring so roles don't nest.
// a11y todo (#1848): the clear <button> is nested inside the activator
// <button> (nested-interactive). The fix is to lift the clear/chip-close
// controls out of the activator so they're siblings (select-only combobox
// pattern), which moves the field's border/hover/focus/error chrome onto a
// wrapper. Deferred: it's a visual-layout refactor that needs in-browser
// verification, not a semantics-only change like the rest of this pass.
parameters: { a11y: { test: "todo" } },
render: () => ({
components: { RSelect },

View File

@@ -5,9 +5,8 @@ import RSlider from "./RSlider.vue";
const meta: Meta<typeof RSlider> = {
title: "Forms/RSlider",
component: RSlider,
// a11y todo (#1848): the slider thumb needs an accessible name (label or
// aria-label). Track a labelling API / required-label lint on RSlider.
parameters: { a11y: { test: "todo" } },
// RSlider has no visible label, so every instance needs `ariaLabel`.
args: { ariaLabel: "Value" },
argTypes: {
min: { control: "number" },
max: { control: "number" },
@@ -115,11 +114,11 @@ export const ColorLadder: Story = {
}),
template: `
<div style="display:flex;flex-direction:column;gap:18px;padding:24px;min-width:380px">
<RSlider v-model="primary" color="primary" value-position="right" value-suffix="%" />
<RSlider v-model="success" color="success" value-position="right" value-suffix="%" />
<RSlider v-model="warning" color="warning" value-position="right" value-suffix="%" />
<RSlider v-model="danger" color="danger" value-position="right" value-suffix="%" />
<RSlider v-model="info" color="info" value-position="right" value-suffix="%" />
<RSlider v-model="primary" color="primary" value-position="right" value-suffix="%" aria-label="Primary" />
<RSlider v-model="success" color="success" value-position="right" value-suffix="%" aria-label="Success" />
<RSlider v-model="warning" color="warning" value-position="right" value-suffix="%" aria-label="Warning" />
<RSlider v-model="danger" color="danger" value-position="right" value-suffix="%" aria-label="Danger" />
<RSlider v-model="info" color="info" value-position="right" value-suffix="%" aria-label="Info" />
</div>
`,
}),
@@ -151,7 +150,7 @@ export const CommitOnEnd: Story = {
},
template: `
<div style="padding:24px;min-width:380px;display:flex;flex-direction:column;gap:10px">
<RSlider v-model="preview" value-position="thumb" value-suffix="%" @end="onEnd" />
<RSlider v-model="preview" value-position="thumb" value-suffix="%" aria-label="Volume" @end="onEnd" />
<div style="font:12px sans-serif;color:var(--r-color-fg-muted)">
previewing: {{ preview }} · last committed: {{ committed }}
</div>

View File

@@ -217,8 +217,6 @@ export const Validation: Story = {
};
export const Loading: Story = {
// a11y todo (#1848): loading spinner (role="progressbar") needs a name.
parameters: { a11y: { test: "todo" } },
args: {
placeholder: "Searching…",
loading: true,
@@ -293,10 +291,6 @@ export const ColorLadder: Story = {
// ── Real-world ─────────────────────────────────────────────────────
export const LoginForm: Story = {
// a11y todo (#1848): the clickable append-inner icon (password reveal)
// renders as a button without an accessible name. Needs an RTextField
// API to label append/prepend-inner actions.
parameters: { a11y: { test: "todo" } },
name: "Login (underlined)",
render: () => ({
components: { RTextField, RBtn },
@@ -309,17 +303,20 @@ export const LoginForm: Story = {
<div style="width:320px;display:flex;flex-direction:column;gap:16px;padding:24px;background:var(--r-color-bg-elevated);border:1px solid var(--r-color-border);border-radius:12px">
<RTextField
v-model="user"
label="Username"
variant="underlined"
placeholder="username"
prepend-inner-icon="mdi-account"
/>
<RTextField
v-model="pass"
label="Password"
variant="underlined"
:type="show ? 'text' : 'password'"
placeholder="password"
prepend-inner-icon="mdi-lock"
:append-inner-icon="show ? 'mdi-eye-off' : 'mdi-eye'"
:append-inner-tooltip="show ? 'Hide password' : 'Show password'"
@click:append-inner="show = !show"
/>
<RBtn block color="primary">Sign in</RBtn>

View File

@@ -58,6 +58,14 @@ interface Props {
/** Tooltip text shown on hover/focus over the append-inner
* adornment. The canonical use is the password-reveal eye icon. */
appendInnerTooltip?: string;
/** Accessible name for the prepend-inner adornment when it is
* interactive (a parent listens to `click:prepend-inner`). Falls back
* to `prependInnerTooltip`. */
prependInnerLabel?: string;
/** Accessible name for the append-inner adornment when it is
* interactive (a parent listens to `click:append-inner`). Falls back
* to `appendInnerTooltip`. */
appendInnerLabel?: string;
autocomplete?: string;
name?: string;
rules?: Rule[];
@@ -111,6 +119,8 @@ const props = withDefaults(defineProps<Props>(), {
appendInnerIcon: undefined,
prependInnerTooltip: undefined,
appendInnerTooltip: undefined,
prependInnerLabel: undefined,
appendInnerLabel: undefined,
autocomplete: undefined,
name: undefined,
rules: () => [],
@@ -357,6 +367,15 @@ function hasListener(name: string): boolean {
const prependInteractive = computed(() => hasListener("click:prepend-inner"));
const appendInteractive = computed(() => hasListener("click:append-inner"));
// An interactive adornment is a real <button>, so it needs an accessible
// name. Prefer the explicit label prop, fall back to the tooltip text.
const prependAdornmentLabel = computed(
() => props.prependInnerLabel ?? props.prependInnerTooltip,
);
const appendAdornmentLabel = computed(
() => props.appendInnerLabel ?? props.appendInnerTooltip,
);
function onPrependInnerClick(evt: MouseEvent) {
// Always emit — emit() is a no-op when nothing's subscribed. The
// listener-detection above only governs the visual treatment
@@ -424,6 +443,7 @@ function onAppendInnerClick(evt: MouseEvent) {
:class="{ 'r-text-field__adornment--interactive': prependInteractive }"
:type="prependInteractive ? 'button' : undefined"
:tabindex="prependInteractive ? 0 : undefined"
:aria-label="prependInteractive ? prependAdornmentLabel : undefined"
@mousedown.prevent
@click="onPrependInnerClick"
>
@@ -505,6 +525,11 @@ function onAppendInnerClick(evt: MouseEvent) {
:tabindex="
appendInteractive && !showLoading && !showClear ? 0 : undefined
"
:aria-label="
appendInteractive && !showLoading && !showClear
? appendAdornmentLabel
: undefined
"
@mousedown.prevent
@click="onAppendInnerClick"
>

View File

@@ -80,15 +80,14 @@ export const Variants: Story = {
};
export const WithNavigation: Story = {
// a11y todo (#1848): role="menuitem" needs its required menu parent. In
// the app RMenu provides it; the bare-item story renders without one.
parameters: { a11y: { test: "todo" } },
render: () => ({
components: { RMenuItem },
setup: () => ({ panelStyle: PANEL_STYLE }),
// Link items carry role="menuitem", which needs a role="menu" parent.
// RMenu supplies that in the app; the bare-item story adds it here.
template: `
<div style="padding:40px">
<div :style="panelStyle">
<div :style="panelStyle" role="menu" aria-label="Navigation">
<RMenuItem to="/platforms" icon="mdi-gamepad-variant-outline" label="Platforms" />
<RMenuItem href="https://romm.app" icon="mdi-open-in-new" label="External link" />
</div>
@@ -102,8 +101,6 @@ export const WithNavigation: Story = {
// and closing would unmount the <a> before the browser opens the new tab.
// A plain click still activates the item normally.
export const NewTabGesture: Story = {
// a11y todo (#1848): role="menuitem" needs its required menu parent.
parameters: { a11y: { test: "todo" } },
name: "New-tab gesture (Ctrl/⌘-click)",
args: {
href: "#platforms",
@@ -116,7 +113,7 @@ export const NewTabGesture: Story = {
setup: () => ({ args, panelStyle: PANEL_STYLE }),
template: `
<div style="padding:40px">
<div :style="panelStyle">
<div :style="panelStyle" role="menu" aria-label="Actions">
<RMenuItem v-bind="args" @click="args.onClick" />
</div>
</div>

View File

@@ -5,14 +5,12 @@ import RProgressCircular from "./RProgressCircular.vue";
const meta: Meta<typeof RProgressCircular> = {
title: "Primitives/RProgressCircular",
component: RProgressCircular,
// a11y todo (#1848): role="progressbar" needs an accessible name. The
// consumer must supply one until RProgressCircular grows a labelling API.
parameters: { a11y: { test: "todo" } },
argTypes: {
indeterminate: { control: "boolean" },
size: { control: "number" },
width: { control: "number" },
color: { control: "text" },
label: { control: "text" },
modelValue: { control: { type: "range", min: 0, max: 100 } },
},
};
@@ -28,7 +26,13 @@ export const Indeterminate: Story = {
};
export const Determinate: Story = {
args: { indeterminate: false, modelValue: 65, size: 64, width: 4 },
args: {
indeterminate: false,
modelValue: 65,
size: 64,
width: 4,
label: "Download progress",
},
};
// ── Size ladder ─────────────────────────────────────────────────────
@@ -71,23 +75,23 @@ export const DeterminateLadder: Story = {
template: `
<div style="display:flex;align-items:flex-end;gap:24px;font:11px/1.2 sans-serif;color:var(--r-color-fg-muted)">
<div style="display:flex;flex-direction:column;align-items:center;gap:8px">
<RProgressCircular :indeterminate="false" :model-value="0" :size="48" :width="4" />
<RProgressCircular :indeterminate="false" :model-value="0" :size="48" :width="4" label="Progress" />
<span>0%</span>
</div>
<div style="display:flex;flex-direction:column;align-items:center;gap:8px">
<RProgressCircular :indeterminate="false" :model-value="25" :size="48" :width="4" />
<RProgressCircular :indeterminate="false" :model-value="25" :size="48" :width="4" label="Progress" />
<span>25%</span>
</div>
<div style="display:flex;flex-direction:column;align-items:center;gap:8px">
<RProgressCircular :indeterminate="false" :model-value="50" :size="48" :width="4" />
<RProgressCircular :indeterminate="false" :model-value="50" :size="48" :width="4" label="Progress" />
<span>50%</span>
</div>
<div style="display:flex;flex-direction:column;align-items:center;gap:8px">
<RProgressCircular :indeterminate="false" :model-value="75" :size="48" :width="4" />
<RProgressCircular :indeterminate="false" :model-value="75" :size="48" :width="4" label="Progress" />
<span>75%</span>
</div>
<div style="display:flex;flex-direction:column;align-items:center;gap:8px">
<RProgressCircular :indeterminate="false" :model-value="100" :size="48" :width="4" />
<RProgressCircular :indeterminate="false" :model-value="100" :size="48" :width="4" label="Progress" />
<span>100%</span>
</div>
</div>

View File

@@ -19,7 +19,7 @@
//
// Default slot — overlay content centred over the ring (percentage
// text, status icon). Lives outside the SVG so it isn't rotated.
import { computed, useSlots } from "vue";
import { computed, getCurrentInstance, useSlots } from "vue";
defineOptions({ inheritAttrs: false });
@@ -34,6 +34,11 @@ interface Props {
color?: string;
/** 0–100. Only consulted when `indeterminate` is false. */
modelValue?: number;
/** Accessible name for the progressbar (e.g. "Upload progress"). An
* indeterminate ring with neither a label nor slot content is treated
* as decorative (aria-hidden) so it doesn't announce as an unnamed
* progressbar; slot content names the ring via aria-labelledby. */
label?: string;
}
const props = withDefaults(defineProps<Props>(), {
@@ -42,10 +47,21 @@ const props = withDefaults(defineProps<Props>(), {
width: 2,
color: "primary",
modelValue: undefined,
label: undefined,
});
const slots = useSlots();
// A ring with no name and no visible value is decorative — usually an
// inline "busy" spinner sitting next to real text. Drop it from the a11y
// tree rather than expose an unnamed progressbar. Slot content (a "35%"
// overlay) names the ring instead, so it's not decorative.
const hasSlotContent = computed(() => !!slots.default);
const decorative = computed(
() => props.indeterminate && !props.label && !hasSlotContent.value,
);
const contentId = `r-pc-label-${getCurrentInstance()?.uid ?? ""}`;
const TONE_MAP: Record<string, string> = {
primary: "var(--r-color-brand-primary)",
secondary: "var(--r-color-brand-secondary)",
@@ -101,11 +117,16 @@ const dashOffset = computed(() => 100 - progressValue.value);
height: `${diameter}px`,
'--r-pc-color': resolvedColor,
}"
role="progressbar"
:aria-valuemin="0"
:aria-valuemax="100"
:aria-valuenow="indeterminate ? undefined : progressValue"
:aria-busy="indeterminate || undefined"
:role="decorative ? undefined : 'progressbar'"
:aria-hidden="decorative ? 'true' : undefined"
:aria-label="!decorative && label ? label : undefined"
:aria-labelledby="
!decorative && !label && hasSlotContent ? contentId : undefined
"
:aria-valuemin="decorative ? undefined : 0"
:aria-valuemax="decorative ? undefined : 100"
:aria-valuenow="!decorative && !indeterminate ? progressValue : undefined"
:aria-busy="!decorative && indeterminate ? true : undefined"
>
<svg class="r-pc__svg" :viewBox="`0 0 ${diameter} ${diameter}`">
<!-- Track — faint underlay so the empty portion still reads
@@ -131,7 +152,7 @@ const dashOffset = computed(() => 100 - progressValue.value);
:stroke-dashoffset="indeterminate ? undefined : dashOffset"
/>
</svg>
<span v-if="slots.default" class="r-pc__content">
<span v-if="slots.default" :id="contentId" class="r-pc__content">
<slot />
</span>
</span>

View File

@@ -4,9 +4,6 @@ import RSpinner from "./RSpinner.vue";
const meta: Meta<typeof RSpinner> = {
title: "Primitives/RSpinner",
component: RSpinner,
// a11y todo (#1848): inherits RProgressCircular's role="progressbar";
// needs an accessible name from the consumer or a component-level default.
parameters: { a11y: { test: "todo" } },
argTypes: {
size: { control: "number" },
width: { control: "number" },