Open Matt-Butler opened 1 day ago
const CustomCheckbox = React.forwardRef(function CustomCheckbox({ 'aria-label': ariaLabel, checked, className, disabled, onChange, tabIndex }: CheckboxProps, ref: React.Ref<HTMLInputElement>) {
return <Checkbox inputProps={{ 'aria-label': ariaLabel }} inputRef={ref} checked={checked} className={className} disabled={disabled} onChange={onChange} tabIndex={tabIndex} />
})
const CustomTreeItem = React.forwardRef(function CustomTreeItem(props: TreeItem2Props, ref: React.Ref<HTMLLIElement>) {
return <TreeItem2 {...props} ref={ref} slots={{ checkbox: (props2) => <CustomCheckbox {...props2} aria-label={props.label} /> }} />
})
export function CustomCheckboxTree() {
return (
<Box sx={{ minHeight: 352, minWidth: 290 }}>
<RichTreeView multiSelect checkboxSelection items={MUI_X_PRODUCTS} slots={{ item: CustomTreeItem }} />
</Box>
)
}
Here is a work around I created.
Thanks for the report
I can confirm that we miss an aria-label
on the checkbox element.
The data grid sets "Select row" / "Unselect row", but we need to introduce a localization behavior to be able to do the same.
Steps to reproduce
Steps:
Current behavior
Accessibility tests fail on checkboxes missing labels.
Expected behavior
Accessibility tests pass
Context
No response
Your environment
``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```npx @mui/envinfo
Search keywords: Tree, Accessibility