Skip to content

Commit

Permalink
fix updateVertexAriaLabel method
Browse files Browse the repository at this point in the history
  • Loading branch information
anakaren-rojas committed Dec 3, 2024
1 parent 170a938 commit e845e00
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions packages/perseus/src/widgets/interactive-graphs/graphs/angle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,17 @@ function AngleGraph({dispatch, graphState}: AngleGraphProps) {
);

const updateVertexAriaLabel = (newPoint: vec.Vector2) => {
showAngles
? setVertexAriaLabel(
strings.srUpdatedVertexWithAngleAtCoordinates({
...formatCoordinates(newPoint[X], newPoint[Y]),
angle: angleLabel,
}),
)
: setVertexAriaLabel(
strings.srUpdatedVertexAtCoordinates(
formatCoordinates(newPoint[X], newPoint[Y]),
),
);
const formattedVertexCoordinates = formatCoordinates(
newPoint[X],
newPoint[Y],
);
const label = showAngles
? strings.srVertexWithAngleAtCoordinates({
...formattedVertexCoordinates,
angle: angleLabel,
})
: strings.srVertexAtCoordinates(formattedVertexCoordinates);
setVertexAriaLabel(label);
};

const updateSideAriaLabel = (
Expand Down Expand Up @@ -177,7 +176,7 @@ function AngleGraph({dispatch, graphState}: AngleGraphProps) {
newPoint: vec.Vector2,
side: "terminal" | "initial",
): unknown => {
updateVertexAriaLabel(newPoint);
updateVertexAriaLabel(coords[1]);
updateSideAriaLabel(side, newPoint);
return dispatch(actions.angle.movePoint(coordIndex, newPoint));
};
Expand All @@ -188,17 +187,7 @@ function AngleGraph({dispatch, graphState}: AngleGraphProps) {
};

React.useEffect(() => {
const formattedVertexCoordinates = formatCoordinates(
coords[1][X],
coords[1][Y],
);
const label = showAngles
? strings.srVertexWithAngleAtCoordinates({
...formattedVertexCoordinates,
angle: angleLabel,
})
: strings.srVertexAtCoordinates(formattedVertexCoordinates);
setVertexAriaLabel(label);
updateVertexAriaLabel(coords[1]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [showAngles]);

Expand Down

0 comments on commit e845e00

Please sign in to comment.