Skip to content

fix: a11y issue fixes #2917

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const LanguageSelectorDropdown: React.FC<LanguageSelectorProps> = ({
<li className="usa-language__primary-item">
<LanguageSelectorButton
className={classes}
aria-controls="language-options"
Copy link
Contributor

Choose a reason for hiding this comment

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

💣 chore: ‏This is a duplicate property, we should remove it.

The ID of the controlled menu is passed as a const via the controls attribute on this component. It's preferable to use the const anyway, so that updating the menu ID does not require an additional update to the controls prop.

label={displayLabel?.label || label || langs[0].label}
isOpen={isOpen}
controls={menuID}
Expand Down
1 change: 1 addition & 0 deletions src/components/Search/SearchButton/SearchButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const SearchButton = ({
name={buttonText}
size={3}
aria-hidden={true}
aria-label="Magnifying glass search icon"
Copy link
Contributor

Choose a reason for hiding this comment

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

💣 chore: There's no need to label this icon, ‏because aria-hidden=true.

Detail:
This icon is hidden from screen readers because it is decorative. The button is already labeled with text, so adding the aria-label would cause AT to read, "Search. Magnifying glass search icon".
I find it helpful to aim for a minimum of text. For instance if I do want to label the Search icon, I would simply use "Search". The fact that it's a magnifying glass (or an icon) doesn't add anything for someone who can't see it.

/>
</Button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/forms/CharacterCount/CharacterCount.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('CharacterCount component', () => {
)
const message = getByTestId('characterCountSRMessage')
expect(message).toHaveClass('usa-character-count__sr-status usa-sr-only')
expect(message).toHaveAttribute('aria-live', 'polite')
expect(message).toHaveAttribute('aria-live', 'off')
})
})

Expand Down Expand Up @@ -232,7 +232,7 @@ describe('CharacterCount component', () => {
)
const message = getByTestId('characterCountSRMessage')
expect(message).toHaveClass('usa-character-count__sr-status usa-sr-only')
expect(message).toHaveAttribute('aria-live', 'polite')
expect(message).toHaveAttribute('aria-live', 'off')
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/CharacterCount/CharacterCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export const CharacterCount = ({
<div
ref={srMessageRef}
className="usa-character-count__sr-status usa-sr-only"
aria-live="polite"
aria-live="off" //https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions#:~:text=Unintuitively%2C%20aria,inside%2C%20the%20element.
data-testid="characterCountSRMessage"
/>
</>
Expand Down
Loading