Unverified Commit 476d5957 authored by Jude Gao's avatar Jude Gao Committed by GitHub

fix: add aria-hidden to error overlay voting icons (#74568)

## What?
Added accessibility improvements to the error overlay voting buttons by making their icons properly hidden from screen readers.

## Why?
To enhance accessibility for users relying on screen readers by preventing redundant icon announcements while maintaining the clear button labels "Mark as helpful" and "Mark as not helpful".

## How?
- Added `ComponentProps<'svg'>` type to ThumbsUp and ThumbsDown components to allow passing SVG attributes
- Spread props to SVG elements to enable aria attributes
- Added test coverage to ensure icons have `aria-hidden="true"`
parent 60eb702f
......@@ -60,6 +60,25 @@ describe('ErrorOverlayLayout Component', () => {
)
).toBeInTheDocument()
})
test('voting buttons have aria-hidden icons', () => {
renderTestComponent()
const helpfulButton = screen.getByRole('button', {
name: 'Mark as helpful',
})
const notHelpfulButton = screen.getByRole('button', {
name: 'Mark as not helpful',
})
expect(helpfulButton.querySelector('svg')).toHaveAttribute(
'aria-hidden',
'true'
)
expect(notHelpfulButton.querySelector('svg')).toHaveAttribute(
'aria-hidden',
'true'
)
})
test('sends feedback when clicking helpful button', async () => {
renderTestComponent()
......
export function ThumbsDown() {
import type { ComponentProps } from 'react'
export function ThumbsDown(props: ComponentProps<'svg'>) {
return (
<svg
width="16"
......@@ -7,6 +9,7 @@ export function ThumbsDown() {
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="thumbs-down-icon"
{...props}
>
<path
fillRule="evenodd"
......
export function ThumbsUp() {
import type { ComponentProps } from 'react'
export function ThumbsUp(props: ComponentProps<'svg'>) {
return (
<svg
width="16"
......@@ -7,6 +9,7 @@ export function ThumbsUp() {
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="thumbs-up-icon"
{...props}
>
<g id="thumb-up-16">
<path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment