-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add predictable ID for help fields, aria describedby attributes #2386
Add predictable ID for help fields, aria describedby attributes #2386
Conversation
Thanks for the PR. I wonder if we can update the changes here with the latest changes just added in #2360. Specifically, can you make sure that all the help / description / title field ids are using the id utility functions you defined in utils.js? Specifically, we might need to change Can we also add snapshot tests as needed for the affected themes, because now the help fields have different ids? |
- Add aria-describedby and id attributes - Use util to create `${id}__description` values
d5acb0d
to
1ad0ec8
Compare
- Add more aria-describedby attributes - Fix use of same id in FieldTemplate
Thank you for the suggestions. I searched for other mentions of I updated the affected snapshots and added more material-ui updates. |
className="control-label" | ||
htmlFor={id} | ||
aria-describedby={ariaDescribedBy(id)}> | ||
<label className="control-label" htmlFor={id}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the original aria-describedby here incorrect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it by mistake here: d332de1
Original is correct: <input>
has id
, <label>
has for
. aria-describedby
goes to the <input>
.
{rawErrors.map((error, i: number) => { | ||
return ( | ||
<ListItem key={i} disableGutters={true}> | ||
<FormHelperText id={id}>{error}</FormHelperText> | ||
<FormHelperText>{error}</FormHelperText> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove the id here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was inside a .map
. If there were multiple errors, it was not unique. Same id was also used with the rawHelp
text. I moved the id to the parent <List>
element and added suffix to both help and error list ids.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Can you add a short section in the "v3 upgrade guide" doc (within the documentation) that describes some of these breaking changes in id's? Just a quick list of what exactly were changed, so that someone who upgrades to v3 will know how the ids will change in the form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we consider this id change to be an internal fix? Element ids must be unique within the document and it is an undocumented feature. Here's a screenshot of the issue from the playground:
In this PR we let the input use the generated id
(no change). To fix the case of non-unique ids and make aria-describedby
behave correctly, we suffix help and errors ids (in material-ui FieldTemplate).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to consider it a breaking change, because this did lead to correct behavior in the past if we just had a single p
element (in which case we'd have a correct, unique id for the p
element).
Hi @ArnoSaine it's been a while, do you remember where we are with this PR? Is this ready except for making it a breaking change / adding it to a v5.x upgrade guide? |
Fixes rjsf-team#959 by reimplementing rjsf-team#2386 making it consistent across all themes - In `@rjsf/utils`, added new `descriptionId()`, `errorId()`, `helpId()`, `titleId()` and `ariaDescribedByIds()` functions with unit tests - In all themes: - Updated the `FieldErrorTemplate` to use the `errorId()` function to generate its id - Updated the `FieldHelpTemplate` to use the `helpId()` function to generate its id - Updated the `ObjectFieldTemplate` to use the `titleId()` and `descriptionId()` functions to generate the ids for the `TitleFieldTemplate` and `DescriptionFieldTemplate` respectively - Updated the `BaseInputTemplate` to pass the `ariaDescribedByIds()` value to `aria-describedby` on the "input" component - For all the widgets that generated a user-accessible "input", passed in the `ariaDescribedByIds()` call into the `aria-describedby` on the "input" component - Updated all the test snapshots to update the `title` and `description` ids to the new values and to add the new `aria-describeby` properties - Updated the documentation to indicate the existance of these new functions - Updated the `5.x migration guide` to document the potential change of ids for Title, Description and `RadioWidget` and `CheckboxWidget` - Updated the `CHANGELOG.md` accordingly
Fixes rjsf-team#959 by reimplementing rjsf-team#2386 making it consistent across all themes - In `@rjsf/utils`, added new `descriptionId()`, `errorId()`, `helpId()`, `titleId()` and `ariaDescribedByIds()` functions with unit tests - In all themes: - Updated the `FieldErrorTemplate` to use the `errorId()` function to generate its id - Updated the `FieldHelpTemplate` to use the `helpId()` function to generate its id - Updated the `ObjectFieldTemplate` to use the `titleId()` and `descriptionId()` functions to generate the ids for the `TitleFieldTemplate` and `DescriptionFieldTemplate` respectively - Updated the `BaseInputTemplate` to pass the `ariaDescribedByIds()` value to `aria-describedby` on the "input" component - For all the widgets that generated a user-accessible "input", passed in the `ariaDescribedByIds()` call into the `aria-describedby` on the "input" component - Updated all the test snapshots to update the `title` and `description` ids to the new values and to add the new `aria-describeby` properties - Updated the documentation to indicate the existance of these new functions - Updated the `5.x migration guide` to document the potential change of ids for Title, Description and `RadioWidget` and `CheckboxWidget` - Also fixed the incorrectly named `__error` to be `__errors` in the `ErrorSchema` examples - Updated the `CHANGELOG.md` accordingly
Fixes rjsf-team#959 by reimplementing rjsf-team#2386 making it consistent across all themes - In `@rjsf/utils`, added new `descriptionId()`, `errorId()`, `helpId()`, `titleId()` and `ariaDescribedByIds()` functions with unit tests - In all themes: - Updated the `FieldErrorTemplate` to use the `errorId()` function to generate its id - Updated the `FieldHelpTemplate` to use the `helpId()` function to generate its id - Updated the `ObjectFieldTemplate` to use the `titleId()` and `descriptionId()` functions to generate the ids for the `TitleFieldTemplate` and `DescriptionFieldTemplate` respectively - Updated the `BaseInputTemplate` to pass the `ariaDescribedByIds()` value to `aria-describedby` on the "input" component - For all the widgets that generated a user-accessible "input", passed in the `ariaDescribedByIds()` call into the `aria-describedby` on the "input" component - Updated all the test snapshots to update the `title` and `description` ids to the new values and to add the new `aria-describeby` properties - Updated the documentation to indicate the existance of these new functions - Updated the `5.x migration guide` to document the potential change of ids for Title, Description and `RadioWidget` and `CheckboxWidget` - Also fixed the incorrectly named `__error` to be `__errors` in the `ErrorSchema` examples - Updated the `CHANGELOG.md` accordingly
Reimplemented in #3380 |
Fixes rjsf-team#959 by reimplementing rjsf-team#2386 making it consistent across all themes - In `@rjsf/utils`, added new `descriptionId()`, `errorId()`, `helpId()`, `titleId()` and `ariaDescribedByIds()` functions with unit tests - In all themes: - Updated the `FieldErrorTemplate` to use the `errorId()` function to generate its id - Updated the `FieldHelpTemplate` to use the `helpId()` function to generate its id - Updated the `ObjectFieldTemplate` to use the `titleId()` and `descriptionId()` functions to generate the ids for the `TitleFieldTemplate` and `DescriptionFieldTemplate` respectively - Updated the `BaseInputTemplate` to pass the `ariaDescribedByIds()` value to `aria-describedby` on the "input" component - For all the widgets that generated a user-accessible "input", passed in the `ariaDescribedByIds()` call into the `aria-describedby` on the "input" component - Updated all the test snapshots to update the `title` and `description` ids to the new values and to add the new `aria-describeby` properties - Updated the documentation to indicate the existance of these new functions - Updated the `5.x migration guide` to document the potential change of ids for Title, Description and `RadioWidget` and `CheckboxWidget` - Also fixed the incorrectly named `__error` to be `__errors` in the `ErrorSchema` examples - Updated the `CHANGELOG.md` accordingly
Fixes rjsf-team#959 by reimplementing rjsf-team#2386 making it consistent across all themes - In `@rjsf/utils`, added new `descriptionId()`, `errorId()`, `helpId()`, `titleId()` and `ariaDescribedByIds()` functions with unit tests - In all themes: - Updated the `FieldErrorTemplate` to use the `errorId()` function to generate its id - Updated the `FieldHelpTemplate` to use the `helpId()` function to generate its id - Updated the `ObjectFieldTemplate` to use the `titleId()` and `descriptionId()` functions to generate the ids for the `TitleFieldTemplate` and `DescriptionFieldTemplate` respectively - Updated the `BaseInputTemplate` to pass the `ariaDescribedByIds()` value to `aria-describedby` on the "input" component - For all the widgets that generated a user-accessible "input", passed in the `ariaDescribedByIds()` call into the `aria-describedby` on the "input" component - Updated all the test snapshots to update the `title` and `description` ids to the new values and to add the new `aria-describeby` properties - Updated the documentation to indicate the existance of these new functions - Updated the `5.x migration guide` to document the potential change of ids for Title, Description and `RadioWidget` and `CheckboxWidget` - Also fixed the incorrectly named `__error` to be `__errors` in the `ErrorSchema` examples - Updated the `CHANGELOG.md` accordingly
Fixes rjsf-team#959 by reimplementing rjsf-team#2386 making it consistent across all themes - In `@rjsf/utils`, added new `descriptionId()`, `errorId()`, `helpId()`, `titleId()` and `ariaDescribedByIds()` functions with unit tests - In all themes: - Updated the `FieldErrorTemplate` to use the `errorId()` function to generate its id - Updated the `FieldHelpTemplate` to use the `helpId()` function to generate its id - Updated the `ObjectFieldTemplate` to use the `titleId()` and `descriptionId()` functions to generate the ids for the `TitleFieldTemplate` and `DescriptionFieldTemplate` respectively - Updated the `BaseInputTemplate` to pass the `ariaDescribedByIds()` value to `aria-describedby` on the "input" component - For all the widgets that generated a user-accessible "input", passed in the `ariaDescribedByIds()` call into the `aria-describedby` on the "input" component - Updated all the test snapshots to update the `title` and `description` ids to the new values and to add the new `aria-describeby` properties - Updated the documentation to indicate the existance of these new functions - Updated the `5.x migration guide` to document the potential change of ids for Title, Description and `RadioWidget` and `CheckboxWidget` - Also fixed the incorrectly named `__error` to be `__errors` in the `ErrorSchema` examples - Updated the `CHANGELOG.md` accordingly
…ts (#3380) * fix: reimplement 2386 to add aria-describedby elements onto all inputs Fixes #959 by reimplementing #2386 making it consistent across all themes - In `@rjsf/utils`, added new `descriptionId()`, `errorId()`, `helpId()`, `titleId()` and `ariaDescribedByIds()` functions with unit tests - In all themes: - Updated the `FieldErrorTemplate` to use the `errorId()` function to generate its id - Updated the `FieldHelpTemplate` to use the `helpId()` function to generate its id - Updated the `ObjectFieldTemplate` to use the `titleId()` and `descriptionId()` functions to generate the ids for the `TitleFieldTemplate` and `DescriptionFieldTemplate` respectively - Updated the `BaseInputTemplate` to pass the `ariaDescribedByIds()` value to `aria-describedby` on the "input" component - For all the widgets that generated a user-accessible "input", passed in the `ariaDescribedByIds()` call into the `aria-describedby` on the "input" component - Updated all the test snapshots to update the `title` and `description` ids to the new values and to add the new `aria-describeby` properties - Updated the documentation to indicate the existance of these new functions - Updated the `5.x migration guide` to document the potential change of ids for Title, Description and `RadioWidget` and `CheckboxWidget` - Also fixed the incorrectly named `__error` to be `__errors` in the `ErrorSchema` examples - Updated the `CHANGELOG.md` accordingly * - Fix test snapshot * - Responded to reviewer feedback by adding and using `optionId()` and `examplesId()` - Added an optional flag to `ariaDescribedByIds()` that, if true, appends the examples id onto the string * - Minor tweak to the `5.x migration guide`
… all inputs (rjsf-team#3380) * fix: reimplement 2386 to add aria-describedby elements onto all inputs Fixes rjsf-team#959 by reimplementing rjsf-team#2386 making it consistent across all themes - In `@rjsf/utils`, added new `descriptionId()`, `errorId()`, `helpId()`, `titleId()` and `ariaDescribedByIds()` functions with unit tests - In all themes: - Updated the `FieldErrorTemplate` to use the `errorId()` function to generate its id - Updated the `FieldHelpTemplate` to use the `helpId()` function to generate its id - Updated the `ObjectFieldTemplate` to use the `titleId()` and `descriptionId()` functions to generate the ids for the `TitleFieldTemplate` and `DescriptionFieldTemplate` respectively - Updated the `BaseInputTemplate` to pass the `ariaDescribedByIds()` value to `aria-describedby` on the "input" component - For all the widgets that generated a user-accessible "input", passed in the `ariaDescribedByIds()` call into the `aria-describedby` on the "input" component - Updated all the test snapshots to update the `title` and `description` ids to the new values and to add the new `aria-describeby` properties - Updated the documentation to indicate the existance of these new functions - Updated the `5.x migration guide` to document the potential change of ids for Title, Description and `RadioWidget` and `CheckboxWidget` - Also fixed the incorrectly named `__error` to be `__errors` in the `ErrorSchema` examples - Updated the `CHANGELOG.md` accordingly * - Fix test snapshot * - Responded to reviewer feedback by adding and using `optionId()` and `examplesId()` - Added an optional flag to `ariaDescribedByIds()` that, if true, appends the examples id onto the string * - Minor tweak to the `5.x migration guide`
… all inputs (rjsf-team#3380) * fix: reimplement 2386 to add aria-describedby elements onto all inputs Fixes rjsf-team#959 by reimplementing rjsf-team#2386 making it consistent across all themes - In `@rjsf/utils`, added new `descriptionId()`, `errorId()`, `helpId()`, `titleId()` and `ariaDescribedByIds()` functions with unit tests - In all themes: - Updated the `FieldErrorTemplate` to use the `errorId()` function to generate its id - Updated the `FieldHelpTemplate` to use the `helpId()` function to generate its id - Updated the `ObjectFieldTemplate` to use the `titleId()` and `descriptionId()` functions to generate the ids for the `TitleFieldTemplate` and `DescriptionFieldTemplate` respectively - Updated the `BaseInputTemplate` to pass the `ariaDescribedByIds()` value to `aria-describedby` on the "input" component - For all the widgets that generated a user-accessible "input", passed in the `ariaDescribedByIds()` call into the `aria-describedby` on the "input" component - Updated all the test snapshots to update the `title` and `description` ids to the new values and to add the new `aria-describeby` properties - Updated the documentation to indicate the existance of these new functions - Updated the `5.x migration guide` to document the potential change of ids for Title, Description and `RadioWidget` and `CheckboxWidget` - Also fixed the incorrectly named `__error` to be `__errors` in the `ErrorSchema` examples - Updated the `CHANGELOG.md` accordingly * - Fix test snapshot * - Responded to reviewer feedback by adding and using `optionId()` and `examplesId()` - Added an optional flag to `ariaDescribedByIds()` that, if true, appends the examples id onto the string * - Minor tweak to the `5.x migration guide`
Reasons for making this change
Make screen reader read field errors, description and help text.
Fixes #959
Checklist
Deploy preview
Once CI finishes, you should be able to view a deploy preview of the playground from this PR at this link: https://deploy-preview-[PR_NUMBER]--rjsf.netlify.app/