Skip to content

Commit

Permalink
fix(Breadcrumb): Hide SVGs from screen readers by adding `aria-hidden…
Browse files Browse the repository at this point in the history
…="true"` to the `span` element that wraps the SVGs. (#1514)

Co-authored-by: Nikita Orliak <[email protected]>
  • Loading branch information
nikitaorliak-cengage and Nikita Orliak authored Oct 25, 2024
1 parent 18ba60b commit f885d59
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/a11y-breadcrumb-hide-svg-from-screen-readers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-magma-dom': patch
---

fix(Breadcrumb): Hide SVGs from screen readers by adding `aria-hidden="true"` to the `span` element that wraps the SVGs.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ describe('Breadcrumb', () => {
expect(getByLabelText('Test label')).toBeInTheDocument();
});

it('should render the breadcrumb component with aria-hidden', () => {
const { container } = render(
<Breadcrumb>
<BreadcrumbItem to="#">{LINK_TEXT}</BreadcrumbItem>
<BreadcrumbItem>{SPAN_TEXT}</BreadcrumbItem>
</Breadcrumb>
);

const span = container.querySelector('span');

expect(span).toHaveAttribute('aria-hidden', 'true');
});

describe('i18n', () => {
it('should use the nav aria-label', () => {
const navAriaLabel = 'test aria label';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const StyledLink = styled.a<{ isInverse?: boolean }>`
: props.theme.colors.neutral700};
text-decoration: none;
cursor: default;
&:hover,
&:focus {
color: ${props =>
Expand Down Expand Up @@ -82,7 +82,7 @@ export const BreadcrumbItem = React.forwardRef<
<Hyperlink to={to} isInverse={isInverse}>
{children}
</Hyperlink>
<StyledSpan isInverse={isInverse} theme={theme}>
<StyledSpan isInverse={isInverse} theme={theme} aria-hidden="true">
<ChevronRightIcon size={theme.iconSizes.small} />
</StyledSpan>
</>
Expand Down

2 comments on commit f885d59

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Please sign in to comment.