From 546a03d8acd377859da65fdd71a416d3b8dd8866 Mon Sep 17 00:00:00 2001 From: Daniel Rafailov Date: Mon, 30 Nov 2026 21:13:34 -0500 Subject: [PATCH 1/3] Added accessible names and descriptions to the graph SVG and hid its decorative parts from screen readers --- CHANGELOG.md | 1 + js/components/graph/Graph.js | 34 +++++- js/components/graph/GraphCanvas.tsx | 14 ++- js/components/graph/Node.tsx | 4 + js/components/graph/__tests__/Graph.test.js | 104 +++++++++++++++++- .../graph/__tests__/GraphCanvas.test.js | 43 ++++++++ .../__snapshots__/Graph.test.js.snap | 7 ++ .../__tests__/__snapshots__/Node.test.js.snap | 2 + js/components/graph/__tests__/a11y.test.js | 81 ++++++++++++++ js/components/graph/a11y.ts | 55 +++++++++ 10 files changed, 338 insertions(+), 7 deletions(-) create mode 100644 js/components/graph/__tests__/a11y.test.js create mode 100644 js/components/graph/a11y.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b3d6bb32..86e011205 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### ✨ New features/enhancements +- Added an accessible name and description to the graph SVG, labelled its course areas and courses groups, and hid decorative parts (arrows, and/or nodes, region shapes, course boxes, filters and spotlights) from screen readers - Changed the colour of hybrid nodes to avoid a visual clash with the darkened background when selecting a focus - Updated section codes on the grid page to match the official timetable builder (listed as LEC/TUT/PRA instead of L/T/P) - Updated text on the course panel of the grid page to better communicate the panel's behaviour diff --git a/js/components/graph/Graph.js b/js/components/graph/Graph.js index 9a1a8ce39..bf768b374 100644 --- a/js/components/graph/Graph.js +++ b/js/components/graph/Graph.js @@ -8,6 +8,7 @@ import Edge from "./Edge" import Node from "./Node" import Button from "./Button" import InfoBox from "./InfoBox" +import { GRAPH_A11Y_TEXT, getGraphA11yDescription, getGraphA11yName } from "./a11y" import GraphCanvas, { NODE_DROPSHADOW_FILTER_ID } from "./GraphCanvas" import Sidebar from "./Sidebar" import { numCredits, transformPoint, formatTransform } from "./util" @@ -921,7 +922,13 @@ export class Graph extends React.Component { ) } - return {Object.values(boolsJSON).map(generateBool)} + // Hidden from screen readers: an "and"/"or" read on its own, away from the + // courses it connects, is meaningless + return ( + + ) } /** @@ -970,7 +977,12 @@ export class Graph extends React.Component { } }) - return {edgesCopy.map(generateEdge)} + // Hidden from screen readers: the arrows are purely visual + return ( + + ) } /** @@ -995,7 +1007,7 @@ export class Graph extends React.Component { nodeDropshadowFilter ) => { return ( - + {Object.values(hybridsJSON).map(entry => { return ( + return ( +