Skip to content

Commit

Permalink
Fix repetitive required field indicator for screen readers
Browse files Browse the repository at this point in the history
`@isRequired` applies both a visual indicator and the `required` attribute on the associated for field, causing a repetitive 'required' when a screen reader user reaches the form element. We set `aria-hidden` to `true` to remove the indicator from the a11y tree and rely on the native HTML attribute to communicate this to users.
  • Loading branch information
alex-ju committed Dec 23, 2022
1 parent f84bd91 commit fa819fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-suits-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hashicorp/design-system-components": patch
---

Fix repetitive required field indicator for screen readers
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#if @isOptional}}
<span class={{this.classNames}}>(Optional)</span>
<span aria-hidden="true" class={{this.classNames}}>(Optional)</span>
{{/if}}
{{#if @isRequired}}
&nbsp;<Hds::Badge class={{this.classNames}} @size="small" @color="neutral" @text="Required" />
&nbsp;<Hds::Badge aria-hidden="true" class={{this.classNames}} @size="small" @color="neutral" @text="Required" />
{{/if}}

0 comments on commit fa819fe

Please sign in to comment.