From 215f343e52462759aefa61dc2b2330967638ff3a Mon Sep 17 00:00:00 2001 From: Nisha Yerunkar Date: Tue, 4 Mar 2025 11:38:23 -0800 Subject: [PATCH 1/3] [stop-safari-empty-images] Add aria-hidden to individual components of interactive graph elements --- .../graphs/components/angle-indicators.tsx | 10 ++++++++++ .../graphs/components/arrowhead.tsx | 5 +++++ .../graphs/components/hairlines.tsx | 8 +++++++- .../graphs/components/movable-point-view.tsx | 5 +++++ .../graphs/components/svg-line.tsx | 5 +++++ .../widgets/interactive-graphs/graphs/polygon.tsx | 12 ++++++++++++ .../widgets/interactive-graphs/graphs/quadratic.tsx | 11 ++++++++++- .../widgets/interactive-graphs/graphs/sinusoid.tsx | 6 ++++++ 8 files changed, 60 insertions(+), 2 deletions(-) diff --git a/packages/perseus/src/widgets/interactive-graphs/graphs/components/angle-indicators.tsx b/packages/perseus/src/widgets/interactive-graphs/graphs/components/angle-indicators.tsx index 6df6d4f865..f2edb30dad 100644 --- a/packages/perseus/src/widgets/interactive-graphs/graphs/components/angle-indicators.tsx +++ b/packages/perseus/src/widgets/interactive-graphs/graphs/components/angle-indicators.tsx @@ -272,6 +272,11 @@ const RightAngleSquare = ({ }) => ( { return ( diff --git a/packages/perseus/src/widgets/interactive-graphs/graphs/components/hairlines.tsx b/packages/perseus/src/widgets/interactive-graphs/graphs/components/hairlines.tsx index e7d035cdf8..690fc7f9fe 100644 --- a/packages/perseus/src/widgets/interactive-graphs/graphs/components/hairlines.tsx +++ b/packages/perseus/src/widgets/interactive-graphs/graphs/components/hairlines.tsx @@ -22,7 +22,13 @@ export default function Hairlines(props: Props) { const [[__, horizontalEndY]] = useTransformVectorsToPixels([0, yMax]); return ( - + { ? "var(--movable-line-stroke-weight-active)" : "var(--movable-line-stroke-weight)", style: {fill: "transparent"}, + // Use aria-hidden to hide the line from screen readers + // so it doesn't read as "image" with no context. + // This is okay because the graph has its own aria-label. + "aria-hidden": true, }} /> {points.map((point, i) => { @@ -453,12 +457,20 @@ const UnlimitedPolygonGraph = (statefulProps: StatefulProps) => { svgPolylineProps={{ strokeWidth: "var(--movable-line-stroke-weight)", style: {fill: "transparent"}, + // Use aria-hidden to hide the line from screen readers + // so it doesn't read as "image" with no context. + // This is okay because the graph has its own aria-label. + "aria-hidden": true, }} /> {/* This rect is here to grab clicks so that new points can be added */} {/* It's important because it stops mouse events from propogating when dragging a points around */} - + {coords.map((coord, i) => { const srQuadraticPoint = getQuadraticPointString( i + 1, diff --git a/packages/perseus/src/widgets/interactive-graphs/graphs/sinusoid.tsx b/packages/perseus/src/widgets/interactive-graphs/graphs/sinusoid.tsx index 846cbb551c..c4ec6d88d3 100644 --- a/packages/perseus/src/widgets/interactive-graphs/graphs/sinusoid.tsx +++ b/packages/perseus/src/widgets/interactive-graphs/graphs/sinusoid.tsx @@ -79,6 +79,12 @@ function SinusoidGraph(props: SinusoidGraphProps) { computeSine(x, coeffRef.current)} color={color.blue} + svgPathProps={{ + // Use aria-hidden to hide the line from screen readers + // so it doesn't read as "image" with no context. + // This is okay because the graph has its own aria-label. + "aria-hidden": true, + }} /> {coords.map((coord, i) => ( Date: Tue, 4 Mar 2025 13:51:32 -0800 Subject: [PATCH 2/3] [stop-safari-empty-images] docs(changeset): [SR] Hide individual visual components of interactive graph elements --- .changeset/wild-apes-repeat.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/wild-apes-repeat.md diff --git a/.changeset/wild-apes-repeat.md b/.changeset/wild-apes-repeat.md new file mode 100644 index 0000000000..ccb86cb923 --- /dev/null +++ b/.changeset/wild-apes-repeat.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": patch +--- + +[SR] Hide individual visual components of interactive graph elements From 68eb743adc15a9a219b32e6cc77e8e2a37447c5c Mon Sep 17 00:00:00 2001 From: Nisha Yerunkar Date: Tue, 4 Mar 2025 13:55:02 -0800 Subject: [PATCH 3/3] [stop-safari-empty-images] update snapshots --- .../interactive-graph.test.tsx.snap | 24 +++++++++++++++++++ .../__snapshots__/movable-line.test.tsx.snap | 22 +++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/packages/perseus/src/widgets/interactive-graphs/__snapshots__/interactive-graph.test.tsx.snap b/packages/perseus/src/widgets/interactive-graphs/__snapshots__/interactive-graph.test.tsx.snap index 13f808a27c..59a221d2d6 100644 --- a/packages/perseus/src/widgets/interactive-graphs/__snapshots__/interactive-graph.test.tsx.snap +++ b/packages/perseus/src/widgets/interactive-graphs/__snapshots__/interactive-graph.test.tsx.snap @@ -932,6 +932,7 @@ exports[`Interactive Graph A none-type graph renders predictably: first render 1