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', () => { ...@@ -60,6 +60,25 @@ describe('ErrorOverlayLayout Component', () => {
) )
).toBeInTheDocument() ).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 () => { test('sends feedback when clicking helpful button', async () => {
renderTestComponent() renderTestComponent()
......
export function ThumbsDown() { import type { ComponentProps } from 'react'
export function ThumbsDown(props: ComponentProps<'svg'>) {
return ( return (
<svg <svg
width="16" width="16"
...@@ -7,6 +9,7 @@ export function ThumbsDown() { ...@@ -7,6 +9,7 @@ export function ThumbsDown() {
fill="none" fill="none"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
className="thumbs-down-icon" className="thumbs-down-icon"
{...props}
> >
<path <path
fillRule="evenodd" fillRule="evenodd"
......
export function ThumbsUp() { import type { ComponentProps } from 'react'
export function ThumbsUp(props: ComponentProps<'svg'>) {
return ( return (
<svg <svg
width="16" width="16"
...@@ -7,6 +9,7 @@ export function ThumbsUp() { ...@@ -7,6 +9,7 @@ export function ThumbsUp() {
fill="none" fill="none"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
className="thumbs-up-icon" className="thumbs-up-icon"
{...props}
> >
<g id="thumb-up-16"> <g id="thumb-up-16">
<path <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