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

fix(material/input): do not override existing aria-describedby value #19587

Conversation

devversion
Copy link
Member

@devversion devversion commented Jun 10, 2020

The form-field notifies controls whenever hints or errors have
been displayed. It does this, so that controls like the input
can refresh their aria-describedby value to point to the errors
and hints.

This currently has the downside of overriding existing
aria-describedby values that have been manually set by
developers. We could fix this by reading the initial value
and merging it with the ids received from the form-field.

Fixes #19528

@devversion devversion added Accessibility This issue is related to accessibility (a11y) target: patch This PR is targeted for the next patch release labels Jun 10, 2020
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 10, 2020
@devversion devversion force-pushed the fix/input-preserve-existing-aria-describedby-value branch 3 times, most recently from 5d0da4a to 57ce77d Compare June 16, 2020 12:03
* Value of `aria-describedby` that should be merged with the described-by ids
* which are set by the form-field.
*/
readonly userAriaDescribedBy?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a bit about this to the docs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's fair. Added it to the guide and updated our custom control example.

Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This method is used by the `<mat-form-field>` to specify the IDs that should be used for the
`aria-describedby` attribute of your component. The method has one parameter, the list of IDs, we
just need to apply the given IDs to our host element.
This method is used by the `<mat-form-field>` to set element ids that should be used for the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I think this makes it a lot more clear why both properties exist / what they're for

@mmalerba mmalerba added lgtm action: merge The PR is ready for merge by the caretaker labels Jun 16, 2020
@devversion devversion added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Jun 16, 2020
@devversion devversion force-pushed the fix/input-preserve-existing-aria-describedby-value branch 2 times, most recently from d8e4bc6 to 34a5f33 Compare June 22, 2020 06:07
@jelbourn
Copy link
Member

@devversion can you rebase when you get a chance?

@devversion devversion force-pushed the fix/input-preserve-existing-aria-describedby-value branch from 34a5f33 to b1908a7 Compare July 29, 2020 07:48
@devversion
Copy link
Member Author

@jelbourn Done

The form-field notifies controls whenever hints or errors have
been displayed. It does this, so that controls like the input
can refresh their `aria-describedby` value to point to the errors
and hints.

This currently has the downside of overriding existing
`aria-describedby` values that have been manually set by
developers. We could fix this by reading the initial value
and merging it with the ids received from the form-field.
@devversion devversion force-pushed the fix/input-preserve-existing-aria-describedby-value branch from b1908a7 to af8c35f Compare July 29, 2020 20:38
@devversion
Copy link
Member Author

devversion commented Jul 29, 2020

This is green now and rebased again.

@mmalerba mmalerba removed the lgtm label Jul 31, 2020
@wagnermaciel wagnermaciel added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Aug 21, 2020
@wagnermaciel wagnermaciel merged commit 7d511ba into angular:master Aug 21, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(input): matInput overwrites aria-described by
5 participants