Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Select][joy] Improve the a11y on the select field demo #34073

Merged
merged 1 commit into from Aug 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/data/joy/components/select/SelectFieldDemo.js
Expand Up @@ -9,15 +9,16 @@ export default function SelectFieldDemo() {
const [value, setValue] = React.useState('dog');
return (
<Box sx={{ width: 240 }}>
<FormLabel>Favorite pet</FormLabel>
<FormLabel htmlFor="select-field-pet">Favorite pet</FormLabel>
<Select
id="select-field-pet"
defaultValue="dog"
componentsProps={{
button: {
// screen readers will announce "Favorite pet, dog selected" when the select is focused.
'aria-label': `Favorite pet, ${value} selected.`,
// and this in the next sentence.
'aria-describedby': 'select-field-demo-helper',
'aria-describedby': 'select-field-pet-helper',
},
}}
value={value}
Expand All @@ -29,7 +30,7 @@ export default function SelectFieldDemo() {
<Option value="fish">Fish</Option>
<Option value="bird">Bird</Option>
</Select>
<FormHelperText id="select-field-demo-helper">
<FormHelperText id="select-field-pet-helper">
This is a helper text.
</FormHelperText>
</Box>
Expand Down