Browser: Chrome 120.0.6099.129 OS: Windows URL: Daveden Test Page Video:
I feel that the Bricks Form Element exhibits some accessibility issues, one of which is the Radio Field and Checkbox Field. Below is the current HTML output for the radio which is similar to the checkbox field:
This structure doesn’t align with recommended HTML patterns outlined in MDN and W3C.
I believe we should either use <fieldset> and <legend>
or <div role=radiogroup aria-labelledby="label id">, and the <label> should be using a different HTML tag like an <h3>.
Otherwise, the group name is not announced to screen readers.
We should not be using ul > li and label HTML tags. Instead, we should use <fieldset> and <legend> or simple divs. See A11y Style Guide, Deque University and MDN
The role=“radiogroup” should be on the wrapper enclosing both the label (ideally an h3, div or user-configurable) and the radio items. Currently, AxeDevTools is throwing an error because the role=“radiogroup” is applied to the <ul>
When we toggle “show label”, then the id is removed from the label.
The role=“group” should be on the wrapper containing both the label and the checkboxes, not the <ul>. AxeDevTools is throwing a similar error about role=“group” is not allowed on a <ul>
The best option is to use a <fieldset> and <legend> as shown on the A11y Style Guide.
I’ve the same problem with Bricks 1.12.3
Also the Honeypot Field shows a problem with Axe Dev Tools.
Fixed both with a JS Snippet below the form:
// Function to modify the aria-labelledby attribute and remove autocomplete="nope"
function modifyAttributes() {
// Part 1: Modify aria-labelledby attributes
// Find all elements in the document with an aria-labelledby attribute
const labelledElements = document.querySelectorAll('[aria-labelledby^="label-"]');
let labelledCount = 0;
// Iterate through all found elements
labelledElements.forEach(element => {
// Get the current value
const currentValue = element.getAttribute('aria-labelledby');
// Replace "label-" with "form-field-" and append "-0" if not already present
let newValue = currentValue.replace('label-', 'form-field-');
if (!newValue.endsWith('-0')) {
newValue = newValue + '-0';
}
// Set the new value
element.setAttribute('aria-labelledby', newValue);
labelledCount++;
});
// Part 2: Remove autocomplete="nope" from ALL text fields (it's added automatically to Honeypot fields)
const textInputs = document.querySelectorAll('input[type="text"]');
let autocompleteCount = 0;
// Iterate through all found text inputs
textInputs.forEach(input => {
// Only remove if autocomplete="nope"
if (input.getAttribute('autocomplete') === 'nope') {
// Remove the autocomplete attribute
input.removeAttribute('autocomplete');
autocompleteCount++;
}
});
}
// Execute the function
modifyAttributes();