primitives icon indicating copy to clipboard operation
primitives copied to clipboard

A11y Bug: Select.Trigger does not correctly pass id to hidden select, breaking Label semantic association

Open jack-rhodes opened this issue 1 year ago • 2 comments

Bug report

Current Behavior

When using the Select primitives with the Label primitive or a html label element, passing an id to the Select.Trigger and a htmlFor to the Label or label does not create a semantic link between the Label and the Select.

This throws issues in automated A11y tooling (Wave shown in screenshots below).

CleanShot 2024-12-17 at 15 59 03@2x CleanShot 2024-12-17 at 15 59 27@2x CleanShot 2024-12-17 at 15 59 49@2x CleanShot 2024-12-17 at 15 59 57@2x

Expected behavior

I had expect this to create the semantic link, adding the id to the hidden select element.

Reproducible example

CodeSandbox repro I had to install a few packages, but this is mostly just your examples from the Select docs with one addition to allow me to pass an id to the SelectDemo component.

Suggested solution

Make the Select.Trigger pass the id correctly?

Additional context

I have come across similar issues before where you folks have well reasoned examples to go around the automated or MDN recommendations for semantic HTML to provide better a11y for actual cases you've tested - perhaps this is one of those?

Your environment

Software Name(s) Version
Radix Package(s) react-select 2.1.4
React n/a 17 (your sandbox) & 18 (our design system)
Browser chrome Version 131.0.6778.140 (Official Build) (arm64)
Assistive tech Wave
Node n/a 20.8.0 (design system)
npm/yarn yarn (design system) 4.0.2
Operating System MacOS 14.7.1 (23H222)

jack-rhodes avatar Dec 17 '24 16:12 jack-rhodes

Could this be related - https://github.com/radix-ui/primitives/issues/2836 ?

jack-rhodes avatar Dec 17 '24 16:12 jack-rhodes

Yes, id is not passed to underlying native select component, which also breaks native form behavior. Making e.g. form to be submittable without data filled in.

Kaspazza avatar Nov 14 '25 15:11 Kaspazza