Skip to content

fix(a11y): skip aria-labelledby when no label element exists#22729

Open
mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
mixelburg:fix/vdatatable-aria-labelledby-22550
Open

fix(a11y): skip aria-labelledby when no label element exists#22729
mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
mixelburg:fix/vdatatable-aria-labelledby-22550

Conversation

@mixelburg
Copy link
Copy Markdown
Contributor

Fixes #22550

Problem

When VTextField, VTextarea, VSelect, VAutocomplete, or VCombobox are used without a label prop (relying on aria-label instead), aria-labelledby was still emitted pointing to ${id}-label — an element ID that doesn't exist in the DOM.

This is an accessibility violation. WCAG requires that aria-labelledby references a real element ID. Screen readers may ignore the working aria-label when a broken aria-labelledby is present (browsers prefer aria-labelledby over aria-label).

Practical example: VDataTableFooter uses VSelect with only aria-label (no label prop), causing the "Items per page" combobox to have a broken ARIA reference that WAVE and browser DevTools flag.

Fix

Conditionally emit aria-labelledby only when props.label or slots.label is provided — i.e. when a corresponding label element will actually be rendered with that ID.

Files changed

  • VTextField.tsx — input element aria-labelledby
  • VTextarea.tsx — textarea element aria-labelledby
  • VSelect.tsx — listbox dropdown aria-labelledby
  • VAutocomplete.tsx — listbox dropdown aria-labelledby
  • VCombobox.tsx — listbox dropdown aria-labelledby

When VTextField, VTextarea, VSelect, VAutocomplete, and VCombobox are
used without a label prop (relying on aria-label instead), the
aria-labelledby attribute was still emitted pointing to an element ID
that doesn't exist in the DOM. This is an accessibility violation that
WAVE and other audit tools flag as a 'broken ARIA reference'.

Fix: set aria-labelledby to undefined when neither props.label nor
slots.label is present, so the aria-label attribute provides the
accessible name instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report][3.11.7] [a11y] Broken ARIA reference in v-data-table footer select

1 participant