why am i getting this WCAG error from ARC toolkit test? 4 Alert(s)Multiple naming…
- User
why am i getting this WCAG error from ARC toolkit test?
4 Alert(s)Multiple naming techniques used Description: The form control uses multiple naming techniques. WCAG 2.2 Success Criterion:A 4.1.2 Name, Role, Value External link
Assistant
You're getting this "Multiple naming techniques used" alert because your
divelements, which are acting as ARIA comboboxes, have botharia-labelandaria-labelledbyattributes on the same element.Let's break down the example:
<div tabindex="0" role="combobox" aria-controls="templateName-select" aria-expanded="false" aria-haspopup="listbox" aria-label="Template Name" aria-labelledby="templateName-select" id="templateName-select" class="MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input css-11u53oe-MuiSelect-select-MuiInputBase-input-MuiOutlinedInput-input"> </div>The Conflict:
aria-label="Template Name": This attribute directly provides an accessible name for the element. Screen readers would announce "Template Name".aria-labelledby="templateName-select": This attribute refers to another element (or elements) by their ID to construct the accessible name. In this case, it's referring toid="templateName-select".
Why this is an issue (or at least an alert):
- Redundancy: You are providing two ways to name the same element. While ARIA has precedence rules (typically
aria-labelledbytakes precedence overaria-label), having both is redundant and can lead to confusion for developers or potentially unexpected behavior with some assistive technologies or browser versions. - Best Practice: It's best practice to choose one clear, unambiguous method for providing an accessible name.
- Misuse of
aria-labelledby(in this specific case): Thearia-labelledbyattribute is designed to point to another element that serves as the label. In your code,aria-labelledby="templateName-select"is pointing to the element itself because the element also hasid="templateName-select". This is generally not howaria-labelledbyis used; it's for referencing a separate visible label. If the element itself contained text,aria-labelledbyreferencing its own ID might make sense to ensure that text is used as the label, but an emptydivrelies on ARIA attributes for its name.
How to fix it:
You need to decide which naming technique is appropriate for your specific use case and remove the other.
Option 1: Use
aria-label(Recommended if "Template Name" is the desired label and there's no separate visual label element)If "Template Name" is simply the accessible name you want this combobox to have, and there isn't a separate, visually rendered label element on the page that says "Template Name" and is linked to this combobox, then
aria-labelis the simplest and clearest choice.<div tabindex="0" role="combobox" aria-controls="templateName-select" aria-expanded="false" aria-haspopup="listbox" aria-label="Template Name" id="templateName-select" class="MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input css-11u53oe-MuiSelect-select-MuiInputBase-input-MuiOutlinedInput-input"> </div> <!-- Removed aria-labelledby -->Option 2: Use
aria-labelledby(Recommended if there is a separate, visible label element)If you have a visible label element on the page that contains the text "Template Name" (e.g., a
labelorspan), and you want to associate that visible label with your combobox for accessibility, then you should usearia-labelledbyand point it to the ID of that separate label element.Example:
<label id="templateName-label" for="templateName-select">Template Name</label> <div tabindex="0" role="combobox" aria-controls="templateName-select" aria-expanded="false" aria-haspopup="listbox" aria-labelledby="templateName-label" id="templateName-select" class="MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input css-11u53oe-MuiSelect-select-MuiInputBase-input-MuiOutlinedInput-input"> </div> <!-- Removed aria-label, aria-labelledby now points to the label's ID -->Note: In this specific case, your
aria-labelledbywas pointing toid="templateName-select", which is the ID of the combobox itself. This implies there's likely no separate label element being referenced, making Option 1 or a re-evaluation of your labeling structure more appropriate.In summary: The alert is a good prompt from ARC Toolkit to review your accessible naming strategy and ensure clarity and efficiency. For your current code, given that
aria-labelledbypoints to the element's own ID, the simplest and most common fix is to removearia-labelledbyand rely solely onaria-label.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.