Accessibility improvement: role="listbox" cannot contain button elements

Created on 26 August 2025, 2 months ago
Updated 31 August 2025, about 2 months ago

Problem/Motivation

In Choices Single Select and Multi-select inputs, after selecting an option, it adds it to a "Selected" container with role="listbox". The option gets added as a <div role="option"> with a Remove Item <button /> inside the div.
This is an accessibility issue, because elements with role="option" cannot contain other elements, especially not actionable elements like buttons. button is not an allowed descendant of an element with role="listbox" or role="option". This confuses the assistive technologies.
See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Referenc... for more information

Steps to reproduce

Found on any choices select input

Proposed resolution

I would propose that upon selecting an option, instead of creating a <div role="option">, create a regular <ul><li>. You can add the Remove Item button to each <li>. There's no reason for the list of selected items to be a listbox, right? The original choices list (choices__list) is still present and hidden.

I'm curious to get your take on whether that breaks something else which was relying on those selected items to have that role of listbox or option.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States mlinnetz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024