Skip to content
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

[SR] Add aria-hidden to individual components of interactive graph elements #2277

Merged
merged 3 commits into from
Mar 6, 2025
Merged
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
5 changes: 5 additions & 0 deletions .changeset/wild-apes-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

[SR] Hide individual visual components of interactive graph elements
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ exports[`Interactive Graph A none-type graph renders predictably: first render 1
</g>
</g>
<g
aria-hidden="true"
class="interactive-graph-arrowhead"
transform="translate(-200 0) rotate(180)"
>
Expand All @@ -949,6 +950,7 @@ exports[`Interactive Graph A none-type graph renders predictably: first render 1
</g>
</g>
<g
aria-hidden="true"
class="interactive-graph-arrowhead"
transform="translate(200 0) rotate(0)"
>
Expand All @@ -966,6 +968,7 @@ exports[`Interactive Graph A none-type graph renders predictably: first render 1
</g>
</g>
<g
aria-hidden="true"
class="interactive-graph-arrowhead"
transform="translate(0 200) rotate(90)"
>
Expand All @@ -983,6 +986,7 @@ exports[`Interactive Graph A none-type graph renders predictably: first render 1
</g>
</g>
<g
aria-hidden="true"
class="interactive-graph-arrowhead"
transform="translate(0 -200) rotate(270)"
>
Expand Down Expand Up @@ -1192,6 +1196,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
aria-label="A polygon."
>
<polygon
aria-hidden="true"
fill-opacity="0.15"
points="3.5 2 2.5 4 1.5 2"
stroke-linejoin="round"
Expand Down Expand Up @@ -1260,6 +1265,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -1320,6 +1326,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -1380,6 +1387,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -1628,6 +1636,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
aria-label="A polygon."
>
<polygon
aria-hidden="true"
fill-opacity="0.15"
points="3 -2 0 3 -3 -2"
stroke-linejoin="round"
Expand Down Expand Up @@ -1657,6 +1666,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -1717,6 +1727,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -1777,6 +1788,7 @@ exports[`Interactive Graph question Should render predictably: after interaction
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -2293,13 +2305,15 @@ exports[`Interactive Graph question Should render predictably: after interaction
aria-label="An empty coordinate plane."
>
<polyline
aria-hidden="true"
fill-opacity="0"
points=""
stroke-linejoin="round"
stroke-width="var(--movable-line-stroke-weight)"
style="fill: transparent; fill-opacity: 0; stroke: var(--movable-line-stroke-color); stroke-opacity: 1; vector-effect: non-scaling-stroke; transform: var(--mafs-view-transform);"
/>
<rect
aria-hidden="true"
height="400"
style="fill: rgba(0,0,0,0); cursor: crosshair;"
width="400"
Expand Down Expand Up @@ -2506,6 +2520,7 @@ exports[`Interactive Graph question Should render predictably: first render 1`]
aria-label="A polygon."
>
<polygon
aria-hidden="true"
fill-opacity="0.15"
points="3.5 2 2.5 4 1.5 2"
stroke-linejoin="round"
Expand Down Expand Up @@ -2574,6 +2589,7 @@ exports[`Interactive Graph question Should render predictably: first render 1`]
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -2634,6 +2650,7 @@ exports[`Interactive Graph question Should render predictably: first render 1`]
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -2694,6 +2711,7 @@ exports[`Interactive Graph question Should render predictably: first render 1`]
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -2942,6 +2960,7 @@ exports[`Interactive Graph question Should render predictably: first render 2`]
aria-label="A polygon."
>
<polygon
aria-hidden="true"
fill-opacity="0.15"
points="3 -2 0 3 -3 -2"
stroke-linejoin="round"
Expand Down Expand Up @@ -2971,6 +2990,7 @@ exports[`Interactive Graph question Should render predictably: first render 2`]
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -3031,6 +3051,7 @@ exports[`Interactive Graph question Should render predictably: first render 2`]
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -3091,6 +3112,7 @@ exports[`Interactive Graph question Should render predictably: first render 2`]
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -3607,13 +3629,15 @@ exports[`Interactive Graph question Should render predictably: first render 4`]
aria-label="An empty coordinate plane."
>
<polyline
aria-hidden="true"
fill-opacity="0"
points=""
stroke-linejoin="round"
stroke-width="var(--movable-line-stroke-weight)"
style="fill: transparent; fill-opacity: 0; stroke: var(--movable-line-stroke-color); stroke-opacity: 1; vector-effect: non-scaling-stroke; transform: var(--mafs-view-transform);"
/>
<rect
aria-hidden="true"
height="400"
style="fill: rgba(0,0,0,0); cursor: crosshair;"
width="400"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,31 @@ exports[`Rendering Does NOT render extensions of line when option is disabled 1`
tabindex="0"
>
<line
aria-hidden="true"
style="stroke: transparent; stroke-width: 44;"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<line
aria-hidden="true"
class="movable-line-focus-outline"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<line
aria-hidden="true"
class="movable-line-focus-outline-gap"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<line
aria-hidden="true"
class=""
data-testid="movable-line__line"
style="stroke: var(--movable-line-stroke-color); stroke-width: var(--movable-line-stroke-weight);"
Expand All @@ -70,6 +74,7 @@ exports[`Rendering Does NOT render extensions of line when option is disabled 1`
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -104,6 +109,7 @@ exports[`Rendering Does NOT render extensions of line when option is disabled 1`
/>
</g>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -173,27 +179,31 @@ exports[`Rendering Does NOT render extensions of line when option is not provide
tabindex="0"
>
<line
aria-hidden="true"
style="stroke: transparent; stroke-width: 44;"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<line
aria-hidden="true"
class="movable-line-focus-outline"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<line
aria-hidden="true"
class="movable-line-focus-outline-gap"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<line
aria-hidden="true"
class=""
data-testid="movable-line__line"
style="stroke: var(--movable-line-stroke-color); stroke-width: var(--movable-line-stroke-weight);"
Expand All @@ -212,6 +222,7 @@ exports[`Rendering Does NOT render extensions of line when option is not provide
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -246,6 +257,7 @@ exports[`Rendering Does NOT render extensions of line when option is not provide
/>
</g>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -315,27 +327,31 @@ exports[`Rendering Does render extensions of line when option is enabled 1`] = `
tabindex="0"
>
<line
aria-hidden="true"
style="stroke: transparent; stroke-width: 44;"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<line
aria-hidden="true"
class="movable-line-focus-outline"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<line
aria-hidden="true"
class="movable-line-focus-outline-gap"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<line
aria-hidden="true"
class=""
data-testid="movable-line__line"
style="stroke: var(--movable-line-stroke-color); stroke-width: var(--movable-line-stroke-weight);"
Expand All @@ -349,12 +365,14 @@ exports[`Rendering Does render extensions of line when option is enabled 1`] = `
style="stroke: var(--movable-line-stroke-color); stroke-width: 2;"
>
<line
aria-hidden="true"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<g
aria-hidden="true"
class="interactive-graph-arrowhead"
transform="translate(0 0) rotate(0)"
>
Expand All @@ -376,12 +394,14 @@ exports[`Rendering Does render extensions of line when option is enabled 1`] = `
style="stroke: var(--movable-line-stroke-color); stroke-width: 2;"
>
<line
aria-hidden="true"
x1="0"
x2="0"
y1="0"
y2="0"
/>
<g
aria-hidden="true"
class="interactive-graph-arrowhead"
transform="translate(0 0) rotate(0)"
>
Expand All @@ -408,6 +428,7 @@ exports[`Rendering Does render extensions of line when option is enabled 1`] = `
tabindex="0"
/>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down Expand Up @@ -442,6 +463,7 @@ exports[`Rendering Does render extensions of line when option is enabled 1`] = `
/>
</g>
<g
aria-hidden="true"
class="movable-point"
data-testid="movable-point"
style="--movable-point-color: #1865f2;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ const RightAngleSquare = ({
}) => (
<MafsCssTransformWrapper>
<path
// Use aria-hidden to hide the line from screen readers
// so it doesn't read as "image" with no context.
// The elements using this should have their own aria-labels,
// so this is okay.
aria-hidden={true}
d={`M ${x1} ${y1} L ${x3} ${y3} M ${x3} ${y3} L ${x2} ${y2}`}
strokeWidth={0.02}
fill="none"
Expand All @@ -286,6 +291,11 @@ const Arc = ({arc, className}: {arc: string; className?: string}) => {
return (
<MafsCssTransformWrapper>
<path
// Use aria-hidden to hide the line from screen readers
// so it doesn't read as "image" with no context.
// The elements using this should have their own aria-labels,
// so this is okay.
aria-hidden={true}
d={arc}
strokeWidth={0.02}
fill="none"
Expand Down
Loading
Loading