@@ -11,7 +11,7 @@ import {
1111 Radio ,
1212} from '@mui/material' ;
1313import isObject from 'lodash.isobject' ;
14- import React , { ReactNode } from 'react' ;
14+ import React , { ReactNode , useId } from 'react' ;
1515
1616interface Option < V = unknown > {
1717 label : string ;
@@ -56,15 +56,17 @@ interface RadioSelectProps<V = unknown> {
5656function RadioSelect < V > ( {
5757 options, onChange, className, label, value, optionToKey = ( o ) => asOption ( o ) . key , name,
5858} : RadioSelectProps < V > ) {
59+ const id = useId ( ) ;
5960 return (
6061 < MenuList className = { `radio-select ${ className } ` } >
6162 { label && ( < FormLabel > { label } </ FormLabel > ) }
6263 { options . map ( ( optionOrValue ) => {
6364 const option = asOption ( optionOrValue ) ;
6465 const checked = Boolean ( value === option . value ) ;
66+ const key = optionToKey ( option ) ;
6567 return (
6668 < MenuItem
67- key = { optionToKey ( option ) }
69+ key = { key }
6870 className = "radio-option"
6971 onClick = { ( ) => {
7072 onChange ?.( { target : { name, value : option . value } } ) ;
@@ -74,12 +76,13 @@ function RadioSelect<V>({
7476 < Radio
7577 checked = { checked }
7678 inputProps = { {
79+ 'aria-labelledby' : `${ id } -${ key } -label` ,
7780 [ ( 'data-testid' as any ) ] : `radio-option__${ optionToKey ( option ) } ` ,
7881 } }
7982 />
8083 < ListItemText
8184 primary = { option . label }
82- primaryTypographyProps = { { className : 'radio-option__title' } }
85+ primaryTypographyProps = { { className : 'radio-option__title' , id : ` ${ id } - ${ key } -label` } }
8386 secondary = { option . caption || '' }
8487 secondaryTypographyProps = { { className : 'radio-option__caption' } }
8588 />
0 commit comments