fix(a11y): give the graph and its controls accessible names - #110
Open
Ravi chandu Edru (RaviChanduEdru) wants to merge 1 commit into
Open
fix(a11y): give the graph and its controls accessible names#110Ravi chandu Edru (RaviChanduEdru) wants to merge 1 commit into
Ravi chandu Edru (RaviChanduEdru) wants to merge 1 commit into
Conversation
Cytoscape paints the ontology into <canvas>, which exposes nothing to assistive technology. The container was a bare <div> with no role, no label, and no text alternative, so a screen reader announced nothing at all for the app's central feature - TODO.md's "Add ARIA labels to the graph visualization". Mark the canvas container role="img" and label it with a summary built from the loaded ontology: name, entity type count, relationship count. The role goes on .graph-canvas rather than .graph-container so the legend and the control buttons stay exposed as their own elements. Entity and relationship names are not folded into the label - they are already reachable as real DOM in the search panel and the legend, and a paragraph-long accessible name reads badly. The summary lives in lib/graphA11y.ts as a pure function so it can be tested without mounting cytoscape in jsdom. The five graph control buttons are icon-only and carried only a title. A title does supply an accessible name, but it is the fragile option - not announced consistently across screen readers and invisible on touch. Add explicit aria-labels and keep title for the mouse tooltip. Verified against the running app: the canvas exposes role="img" named "Fourth Coffee ontology graph: 6 entity types, 7 relationships. Interactive diagram.", the label tracks the loaded ontology when switching to E-Commerce Platform, and all five controls resolve and activate by their accessible names. No console errors. Keyboard navigation of the graph itself is a separate TODO item and is not addressed here.
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.
Picks up the unchecked "Add ARIA labels to the graph visualization" item from
TODO.md, continuing the recent accessibility work (#75, #77, #78).The problem
Cytoscape paints the ontology into
<canvas>elements, which expose nothing to assistive technology. The container is a bare div:No role, no label, no text alternative — a screen reader announces nothing at all for the app's central feature.
The change
The graph canvas gets
role="img"and an accessible name built from the loaded ontology — name, entity-type count, relationship count:Two deliberate choices there:
.graph-canvas, not.graph-container.role="img"prunes descendants from the accessibility tree, and the container also holds the legend and the control buttons — putting it there would have hidden them.The summary lives in
src/lib/graphA11y.tsas a pure function, so it's testable without mounting cytoscape in jsdom.The five control buttons are icon-only and carried only a
title. To be precise:titledoes supply an accessible name for an icon-only button, so this wasn't a violation — but it's the fragile option, announced inconsistently across screen readers and invisible on touch. They now carry explicitaria-labels, withtitlekept for the mouse tooltip.Verification
5 unit tests cover the summary: counts, singular/plural agreement, an empty ontology, and the unnamed/whitespace-name fallback.
Driven against the running app with Playwright:
role="img"No console errors. Only existing theme tokens are involved, so the contrast suite is untouched.
Scope
OntologyGraph.tsx, but a different region (the legend), so they merge cleanly in either order.npm teston this branch shows one unrelated pre-existing failure —compile-catalogue.test.tstiming out under Vitest's 5s default — which is what fix(lint): repair no-case-declarations errors and gate lint in CI #108 fixes.