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

feat(LEMS-1733): adds aria labels to line segment #2032

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

anakaren-rojas
Copy link
Contributor

@anakaren-rojas anakaren-rojas commented Dec 18, 2024

Summary:

  • Adds aria label and description to whole line segment
  • Adds aria label for individual end points of line segment

Issue: LEMS-1733

Test plan:

  1. Navigate to Chromatic
  2. Select Line Segment Interactive Graph from drop down
  3. Validate screen reader can read line segment

Expected behavior

  1. Screen reader reads aria label for whole graph: A line segment on a coordinate plane
  2. Screen reader reads aria description for whole graph: Endpoint 1 at ${point1X} comma ${point1Y}. Endpoint 2 ${point2X} comma ${point2Y}. Segment length %(length)s
  3. When selected, screen reader reads aria label for end points: Endpoint ${endpointNumber} at ${x} comma ${y}
  4. When moving a point, aria labels adjust to include new end points and length, as appropriate

Screenshots:

image

@anakaren-rojas anakaren-rojas self-assigned this Dec 18, 2024
Copy link
Contributor

github-actions bot commented Dec 18, 2024

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (0616ef8) and published it to npm. You
can install it using the tag PR2032.

Example:

yarn add @khanacademy/perseus@PR2032

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR2032

Copy link
Contributor

github-actions bot commented Dec 18, 2024

Size Change: +386 B (+0.03%)

Total Size: 1.27 MB

Filename Size Change
packages/perseus/dist/es/index.js 417 kB +225 B (+0.05%)
packages/perseus/dist/es/strings.js 5.09 kB +161 B (+3.27%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 4.26 kB
packages/math-input/dist/es/index.js 78 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 1.48 kB
packages/perseus-editor/dist/es/index.js 688 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/pure-markdown/dist/es/index.js 3.67 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@anakaren-rojas anakaren-rojas changed the title docs(changeset): adds aria labels to line segment feat(LEMS01733): adds aria labels to line segment Dec 18, 2024
@anakaren-rojas anakaren-rojas changed the title feat(LEMS01733): adds aria labels to line segment feat(LEMS-1733): adds aria labels to line segment Dec 18, 2024
@anakaren-rojas anakaren-rojas marked this pull request as ready for review December 18, 2024 23:34
Copy link
Contributor

@nishasy nishasy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small requests.

context:
"Screenreader-only description of a line segment on a coordinate plane.",
message:
"Endpoint 1 at %(point1X)s comma %(point1Y)s. Endpoint 2 %(point2X)s comma %(point2Y)s. Segment length %(length)s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put a period at the end of this sentence? It can sound weird when there are multiple sentences and one of them doesn't have it when the screen reader is reading them back to back.

Also, I think this one is supposed to end with "Segment length %(length)s units." according to the SRUX doc.

srSegmentGraphEndpointAriaLabel: {
context:
"Screenreader-accessible label for an endpoint of a line segment on a coordinate plane.",
message: "Endpoint $(endpointNumber)s at $(x)s comma $(y)s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a period at the end of this one too?

point2X: srFormatNumber(segments[0][1][X], locale),
point2Y: srFormatNumber(segments[0][1][Y], locale),
length: srFormatNumber(lengthOfSegment, locale),
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: I know why this is happening. You have to use unique IDs to fix this. You can see how I did this for circle and linear if you need a reference.

I'm not really sure what's going on, but it seems like this is somehow using the correct answer or default coordinates instead of the ones that are on the graph? I'm extra confused because your implementation looks right to me... 🤔

It has the right values for the points themselves, just not for the aria describedby.

Screen.Recording.2024-12-18.at.5.04.27.PM.mov

/>
))}
</>
<g id="segment-description" style={{display: "hidden"}}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use React.useId() to create unique IDs. If there are ever multiple segment interactive graphs on the screen, they'd both read the description for the first one.

OHH!!! I JUST FIGURED OUT THE PROBLEM FROM THE ABOVE COMMENT WHILE WRITING THIS!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants