[Interactive Graph] Add WB Announcer to Quadratic graph.#3678
Open
catandthemachines wants to merge 2 commits into
Open
[Interactive Graph] Add WB Announcer to Quadratic graph.#3678catandthemachines wants to merge 2 commits into
catandthemachines wants to merge 2 commits into
Conversation
Contributor
|
Size Change: +159 B (+0.03%) Total Size: 505 kB 📦 View Changed
ℹ️ View Unchanged
|
Contributor
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (3cad008) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR3678If you are working in Khan Academy's frontend, you can run the below command. ./dev/tools/bump_perseus_version.ts -t PR3678If you are working in Khan Academy's webapp, you can run the below command. ./dev/tools/bump_perseus_version.js -t PR3678 |
Member
Author
There was a problem hiding this comment.
Moved these functions to screenreader-text.ts to avoid circular dependency.
| // (Undefined means the quadratic graph is a line and has no vertex.) | ||
| const srQuadraticVertex = | ||
| a !== 0 ? getQuadraticVertexString(vertex, strings) : undefined; | ||
| vertex === undefined |
Member
Author
There was a problem hiding this comment.
Since the vertex is now calculated using the above function. It will return defined or undefined if there is a vertex to describe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Wires the Quadratic graph's
movePointaction into the WB Announcerpipeline.
What this PR does:
case "quadratic"indoMovePointnow emitsstateAnnouncement: {type: "move-quadratic-point", pointIndex, x, y, vertex}.The reducer pre-computes the vertex from the new quadratic
coefficients —
vertexisnullwhena === 0(the paraboladegenerates to a line and has no vertex).
MoveQuadraticPointAnnouncementtoInteractiveGraphStateAnnouncement.getAnnouncementTexthandles"move-quadratic-point"by composing the quadrant-aware point labelwith the vertex string when present:
getQuadraticPointString(pointIndex + 1, [x, y], strings, locale)for the moved point(origin / on-axis / quadrant 1-4 variants)
vertex \!== null, appendsgetQuadraticVertexString(vertex, strings)(origin / on-axis / quadrant 1-4 variants)
getCoordQuadrant,getQuadraticVertexString,and
getQuadraticPointStringfromgraphs/utils.tstographs/screenreader-text.ts.utils.tswas already importingsrFormatNumberfromscreenreader-text.ts, so importing thequadratic string helpers back would have created a cycle. Moving them
keeps the dependency one-way (
utils.ts→screenreader-text.ts).quadratic.tsxis updated to import the helpers from their new home.ariaLive="off"to eachMovablePointso the WB Announcer is the only source of move announcements for
quadratic. Includes a
TODO(LEMS-4189)on the call site to removethe prop once
aria-liveis dropped fromuseControlPoint.movePointon quadratic (a normalmove emits the announcement with a non-null
vertex; a move thatproduces collinear points emits the announcement with
vertex: null),and four
screenreader-texttests covering each branch of thecomposed label (point in a quadrant + vertex in a quadrant, point on
an axis + vertex at the origin, point at the origin + vertex on an
axis, degenerate-line case where the vertex is omitted entirely).
Issue: LEMS-4192
Test plan:
Automated
pnpm tsc— passespnpm lint packages/perseus— passesManual (reviewer)
pnpm storybook). Turn on VoiceOver / NVDA (or use the Storybook a11y addon's live-region inspector).aria-label(unchanged — still includes the vertex context).aria-liveand the WB Announcer would have fired.y = x). Move one of them and confirm the announcement is only the point label — no vertex sentence — since the parabola has degenerated to a line.