Skip to content

Commit

Permalink
[SR][Locked Figures] Give all locked figures "img" role (#2097)
Browse files Browse the repository at this point in the history
## Summary:
Right now, when traversing through locked figures with a
screen reader, it reads out the label and then identifies
the figure as "empty group." This is an extremely
unhelpful description.

To give a more accurate description of the function the
locked figures are serving, we need to give them a
role of "img." This way, the screen reader will read
the aria label and then say "image" after.

Issue: none

## Test plan:
Storybook
- http://localhost:6006/iframe.html?globals=&args=&id=perseuseditor-widgets-interactive-graph--mafs-with-locked-figures&viewMode=story
- Go through this story before and after the change. It should say image
  instead of empty group now.

### Before

https://github.com/user-attachments/assets/245cd639-a64b-4abf-bcc3-9354a6381c8d


### After

https://github.com/user-attachments/assets/68c67c9b-160e-4949-a123-209e28759b4e

Author: nishasy

Reviewers: SonicScrewdriver

Required Reviewers:

Approved By: SonicScrewdriver

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x)

Pull Request URL: #2097
  • Loading branch information
nishasy authored Jan 14, 2025
1 parent b846392 commit 7ed21f4
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-fireants-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

[SR][locked figures] Give all locked figures "img" role
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const LockedEllipse = (props: LockedEllipseType) => {
className="locked-ellipse"
aria-label={hasAria ? ariaLabel : undefined}
aria-hidden={!hasAria}
role="img"
>
<Ellipse
center={center}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const LockedFunction = (props: LockedFunctionType) => {
className="locked-function"
aria-label={hasAria ? props.ariaLabel : undefined}
aria-hidden={!hasAria}
role="img"
>
{directionalAxis === "x" && (
<Plot.OfX y={(x) => equation.eval({x})} {...plotProps} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const LockedLine = (props: Props) => {
className={kind === "ray" ? "locked-ray" : "locked-line"}
aria-label={hasAria ? ariaLabel : undefined}
aria-hidden={!hasAria}
role="img"
>
{line}
{showPoint1 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const LockedPoint = (props: LockedPointType) => {
className="locked-point"
aria-label={hasAria ? ariaLabel : undefined}
aria-hidden={!hasAria}
role="img"
>
<Point
x={x}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const LockedPolygon = (props: LockedPolygonType) => {
className="locked-polygon"
aria-label={hasAria ? props.ariaLabel : undefined}
aria-hidden={!hasAria}
role="img"
>
<Polygon
points={[...points]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const LockedVector = (props: LockedVectorType) => {
className="locked-vector"
aria-label={hasAria ? ariaLabel : undefined}
aria-hidden={!hasAria}
role="img"
>
<Vector tail={tail} tip={tip} color={lockedFigureColors[color]} />
</g>
Expand Down

0 comments on commit 7ed21f4

Please sign in to comment.