Skip to content

[Interactive Graph] Add WB Announcer to Linear graph#3683

Draft
catandthemachines wants to merge 2 commits into
mainfrom
catjohnson/wb-announcer-linear
Draft

[Interactive Graph] Add WB Announcer to Linear graph#3683
catandthemachines wants to merge 2 commits into
mainfrom
catjohnson/wb-announcer-linear

Conversation

@catandthemachines
Copy link
Copy Markdown
Member

@catandthemachines catandthemachines commented May 29, 2026

Summary:

Wires the Linear graph's movePoint (endpoint) and moveLine (whole-line
grab handle) actions into the existing WB Announcer pipeline.

What this PR does:

  • Reducer: case "linear" in doMovePointInFigure now emits
    stateAnnouncement: {type: "move-linear-point", pointIndex, x, y} when an
    endpoint moves. case "linear" in doMoveLine emits
    stateAnnouncement: {type: "move-linear-line", coords} when the whole
    line is dragged via the grab handle. Both case "linear" blocks are split
    out from the shared case "ray"/case "vector" blocks so ray and vector
    (not yet migrated) are intentionally untouched.
  • Types: adds MoveLinearPointAnnouncement and MoveLinearLineAnnouncement
    to InteractiveGraphStateAnnouncement.
  • Screen reader text: getAnnouncementText handles "move-linear-point"
    with the generic srPointAtCoordinates string ("Point N at X comma Y.",
    matching the endpoints' aria-label) and "move-linear-line" with
    srLinearGrabHandle ("Line going through point X1 comma Y1 and point X2
    comma Y2."
    ).
  • Component: adds an optional ariaLive override prop to MovableLine. It
    defaults to undefined, preserving the internal aria-live state machine
    for the other graphs that still share MovableLine (ray, segment,
    linear-system). linear.tsx passes ariaLive="off" so the WB Announcer
    is the only source of move announcements for the Linear graph.
  • TODOs reference LEMS-4189,
    which tracks removing aria-live from useControlPoint and MovableLine
    once every line graph's reducer is wired to the announcer.
  • Tests: adds reducer tests for movePoint and moveLine on linear, adds
    two screenreader-text tests (move-linear-point + move-linear-line),
    and removes the now-obsolete "Should update the aria-live when X is moved"
    test from linear.test.tsx.

Issue: LEMS-4198

Test plan:

Automated

  • pnpm tsc — passes
  • pnpm lint packages/perseus — passes
  • pnpm jest packages/perseus/src/widgets/interactive-graphs — passes

Manual (reviewer)

  • Open the Interactive Graph → Linear story in Storybook (pnpm storybook). Turn on VoiceOver / NVDA (or use the Storybook a11y addon's live-region inspector).
  • Tab to one of the endpoint handles. Confirm the initial focus announces "Point N at X comma Y." (from aria-label, unchanged).
  • Press arrow keys to move the endpoint one snap step at a time. Confirm:
    • You hear "Point N at X comma Y." after each move (new WB Announcer payload).
    • You do not hear the announcement twice. Before this PR, both the endpoint's aria-live and the WB Announcer would have fired.
  • Tab to the line itself (the whole-line grab handle). Press arrow keys to drag the line. Confirm you hear "Line going through point X1 comma Y1 and point X2 comma Y2." after each keyboard drag — this is the new move-linear-line announcement, and you should hear it only once.
  • Regression: open the Ray, Segment, and Linear System stories and confirm they still announce moves the same way they did before (their behavior is unchanged in this PR).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

npm Snapshot: Published

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

Example:

pnpm add @khanacademy/perseus@PR3683

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3683

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3683

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

Size Change: +167 B (+0.03%)

Total Size: 506 kB

📦 View Changed
Filename Size Change
packages/perseus/dist/es/index.js 199 kB +167 B (+0.08%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.6 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.32 kB
packages/math-input/dist/es/index.js 98.5 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 12.1 kB
packages/perseus-core/dist/es/index.js 26.1 kB
packages/perseus-editor/dist/es/index.js 105 kB
packages/perseus-linter/dist/es/index.js 9.41 kB
packages/perseus-score/dist/es/index.js 10.2 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 8.55 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

return `${srCircleRadiusPointLabel(state.x, state.y, state.centerX, strings, locale)} ${strings.srCircleRadius({radius: state.radius})}`;
case "move-center":
return srCircleCenterLabel(state.x, state.y, strings, locale);
case "move-linear-point":
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nit: Let me consolidate this with the generic move-point announcement. No need to duplicate if it's the same.

}
case "linear":
case "linear": {
const constrainedLine = constrainShapePreservingMove(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

nit: Add a similar comment like above so this logic is consoludated once ray and vector are moved over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant