-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Form field aria-describedby fixes #30015
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
Conversation
Currently we set the `aria-describedby` every time the state of the form control changes. This is excessive, because it only needs to happen if the error state or `userAriaDescribedBy` change.
Currently there are two sources of an `aria-describedby` for a `matInput`: the IDs of the hint/error message in the form field and any custom ones set through `aria-describedby`. This is insufficient, because the ID can also come from a direct DOM manupulation like in the `AriaDescriber`. These changes tweak the logic to try and preserve them, because currently they get overwritten. Fixes angular#30011.
|
|
||
| // Updating the `aria-describedby` touches the DOM. Only do it if it actually needs to change. | ||
| this._describedByChanges?.unsubscribe(); | ||
| this._describedByChanges = control.stateChanges |
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 tried basing this on top of signals, but the timing was off because I had to run _syncDescribedByIds in an effect.
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.
Ideally we'll do a bigger refactor at some point and replace syncDescribedByIds with a signal, describedByIds
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.
Yep, I'd argue pretty much all the properties in the FormFieldControl should be signals.
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Includes the following fixes for how we deal with
ariab-describedbyin the form field:fix(material/form-field): avoid touching the DOM on each state change
Currently we set the
aria-describedbyevery time the state of the form control changes. This is excessive, because it only needs to happen if the error state oruserAriaDescribedBychange.fix(material/input): preserve aria-describedby set externally
Currently there are two sources of an
aria-describedbyfor amatInput: the IDs of the hint/error message in the form field and any custom ones set througharia-describedby. This is insufficient, because the ID can also come from a direct DOM manipulation like in theAriaDescriber.These changes tweak the logic to try and preserve them, because currently they get overwritten.
Fixes #30011.