Skip to content

Made the graph controls and sidebar toggle keyboard and screen reader accessible - #1849

Merged
david-yz-liu merged 2 commits into
Courseography:masterfrom
danielrafailov:graph-controls-accessibility
Dec 2, 2026
Merged

david-yz-liu merged 2 commits into
Courseography:masterfrom
danielrafailov:graph-controls-accessibility

Conversation

@danielrafailov

@danielrafailov danielrafailov commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Proposed Changes

The first of the graph accessibility PRs discussed earlier (the graph controls). The zoom in, zoom out and reset view buttons and the sidebar toggle can't be used properly with a keyboard or screen reader:

  • Enter and Space didn't activate the zoom and reset view buttons. They used onMouseDown, which only fires for a real mouse press, so pressing Enter on a focused zoom button did nothing. (VoiceOver's VO+Space worked, since it simulates a full mouse click.)
  • Keyboard focus was invisible on these buttons. .graph-control-button set outline: none, so there was no way to tell which one was focused.
  • The zoom buttons had no accessible name. Their only content is a Font Awesome icon marked aria-hidden, so Chrome's Accessibility pane showed Name: "" and screen readers just said "button".
  • The sidebar toggle (the arrow under the FCE count) couldn't be reached with Tab. It was a <div> with an onClick, and its image had no alt, so it also had no meaningful name.

Changes:

  • Button.tsx: added an onClick prop (fires for mouse clicks, Enter and Space) and an ariaLabel prop that sets aria-label. The existing mouseDown prop is unchanged.
  • Graph.js:
    • The zoom in, zoom out and reset view buttons now use onClick instead of mouseDown.
    • The zoom buttons are labelled "Zoom in" and "Zoom out". The reset view button already gets its name from its image's alt="Reset View".
  • Sidebar.tsx:
    • The sidebar toggle is now a <button type="button">, so it's reachable with Tab and works with Enter and Space.
    • It's labelled "Course sidebar" and has aria-expanded, so screen readers announce e.g. "Course sidebar, collapsed, button". It also has aria-controls, pointing to the panel's new id="sidebar-dropdown".
    • The arrow image has alt="", since it's decorative and the button is already labelled.
  • app.scss:
    • Removed outline: none from .graph-control-button and added a :focus-visible outline, using the existing --primary-color. :focus-visible shows the outline for keyboard focus but not after a mouse click, so nothing changes for mouse users. The same outline is added to .sidebar-button.
    • Added border: 0 and align-items: center to .sidebar-button, so the new <button> looks the same as the old <div>: no default 3D border, and the arrow in the same position.
  • Tests:
    • Button.test.js: ariaLabel sets the accessible name, and onClick is called on a mouse click, Enter and Space.
    • Graph.test.js: the zoom and reset view buttons have accessible names, Enter on each zoom button zooms, and Enter on reset view resets the view.
    • Sidebar.test.js: the toggle has the right name, aria-expanded and aria-controls, and Enter opens the sidebar. The Sidebar snapshot is updated for the <div> → <button> change.

I tested this in Chrome (mouse, Tab and Enter/Space, and the Accessibility pane) and in Safari with VoiceOver. For mouse users the only difference is that the zoom and reset buttons now act when the mouse button is released rather than pressed.

Screenshots of your changes (if applicable)

Zoom in button focused with Tab, before the change (no visible focus):
Screenshot 2026-11-29 at 5 55 54 PM
Zoom in button focused with Tab, after the change:
Screenshot 2026-11-29 at 5 54 14 PM
Sidebar toggle focused with Tab, after the change (not reachable with Tab before):
Screenshot 2026-11-29 at 5 57 30 PM
Chrome Accessibility pane for the zoom in button, before the change (Name: ""):
Screenshot 2026-11-29 at 5 59 11 PM
Chrome Accessibility pane for the zoom in button, after the change (Name: "Zoom in"):
Screenshot 2026-11-29 at 5 58 34 PM

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
✨ New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue) X
🎨 User interface change (change to user interface; provide screenshots) X
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.
  • I have updated the project Changelog (this is required for all changes).

After opening your pull request:

  • I have verified that the CI checks have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

  • As you suggested, the alt text for the exported graph image will be in its own PR.
  • The "X" buttons in the sidebar's selected courses list use the same Button component with mouseDown, so Enter doesn't work on them either. Switching them to onClick also needs stopPropagation, since a click would otherwise reach the course row's own onClick. I left them out to keep this PR to the controls we discussed, but I can fix them here or in a follow-up.
  • The sidebar's "Reset Selections" button also sets outline: none, so its keyboard focus is invisible too. It's the same two-line fix as the graph buttons. Happy to add it here if you'd like.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 46320251721

Coverage increased (+0.09%) to 62.404%

Details

  • Coverage increased (+0.09%) from the base build.
  • Patch coverage: 2 of 2 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4327
Covered Lines: 2749
Line Coverage: 63.53%
Relevant Branches: 1014
Covered Branches: 584
Branch Coverage: 57.59%
Branches in Coverage %: Yes
Coverage Strength: 148.42 hits per line

💛 - Coveralls

@david-yz-liu david-yz-liu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @danielrafailov. These changes look great, and so I'm going to merge in this PR now, but you can make the two other improvements you suggested in the PR comments in a separate pull request.

@david-yz-liu
david-yz-liu merged commit da93eeb into Courseography:master Dec 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants