fix(landing): make map switcher and menu toggle keyboard accessible - #4
Open
olitreadwell wants to merge 1 commit into
Open
fix(landing): make map switcher and menu toggle keyboard accessible#4olitreadwell wants to merge 1 commit into
olitreadwell wants to merge 1 commit into
Conversation
- The layer switcher was a div with onClick, so keyboard and screen-reader users could not reach or operate it. Give it role=button, tabindex, an aria-label, and Enter/Space key handling, plus a visible focus outline. - The header menu toggle was a clickable <i> icon. Replace it with a real button that has an aria-label and aria-expanded, and hide the icon from assistive tech. - Reset the native button chrome in CSS so the icon looks unchanged. Both controls now meet WCAG 2.1.1 (Keyboard) and 4.1.2 (Name, Role, Value).
olitreadwell
force-pushed
the
fix/landing-a11y-keyboard-controls
branch
from
August 18, 2026 22:51
8a6209d to
5d86496
Compare
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.
Motivation
Two of the map viewer's own controls can only be used with a mouse.
They are built from non-interactive HTML elements, so keyboard and screen-reader users cannot reach or operate them:
<div onClick>. It is not in the tab order, does not respond to Enter/Space, and has no button role, so assistive tech does not announce it as a control.<i onClick>. Same problem: not focusable, not keyboard-operable, no role, no accessible name, and no open/closed state exposed.For a public government map viewer this is a real barrier.
It fails WCAG 2.1 2.1.1 Keyboard (all functionality available from a keyboard) and 4.1.2 Name, Role, Value (controls must expose a name, a role, and their state).
Self-found gap: there is no existing upstream issue for this.
Modifications
map.switcher.tsx: kept the element a<div>(it wraps another<div>, which is not valid inside a<button>) and made it behave like a button:role="button",tabIndex={0}, anaria-label, and anonKeyDownhandler that activates it on Enter and Space (withpreventDefaultso Space does not scroll the page). The existing click behaviour is unchanged.layout.header.tsx: replaced the clickable<i>with a real<button type="button">wrapping the icon. Addedaria-label("Open menu" / "Close menu") andaria-expandedso the toggle state is announced. The icon is nowaria-hidden(decorative). The mouse-only inlinecursor: pointeris removed, the button gets it from the existing global rule.static/index.css: reset the native chrome on the new menu button so the icon looks exactly as before, and added a:focus-visibleoutline on the layer switcher so keyboard focus is visible (WCAG 2.4.7 Focus Visible).One coherent change: make the two custom map controls keyboard-operable and properly labelled.
No behaviour change for existing mouse users.
How to verify
Ran in
packages/landingon Node 24:Accessibility, reasoned per control (before → after):
title(not a reliable accessible name). After: reachable by Tab, announced as "Switch map to …, button", operable with Enter and Space, visible focus ring.<i>not focusable, no role/name/state. After, a real<button>, in the tab order, announced as "Open menu, button" / "Close menu, button" with expanded/collapsed state, Enter/Space work natively.The repo has no component-DOM test harness (tests run via
node --teston compiled JS, no jsdom/testing-library), so this is verified by build + lint + type-check + the existing suite staying green, plus the concrete control-by-control reasoning abov: not by a new UI test.AI disclosure: Drafted with AI assistance.
I found the gap, verified the fix against the current code, ran the build/lint/tests, and reviewed the diff line by line.
AI code review (open-code-review, delegation mode): clean.
Promote upstream with:
No CLA, DCO, or commit signing is required by this repo.
Commit message and this PR title follow Conventional Commits, matching the repo's PR-title lint.
AI assistance
Drafted with AI assistance. The change was verified before opening, and the diff was reviewed line by line.
PROMOTION NOTE (remove this section before/when opening against upstream):
Open the compare view to create the upstream PR (scoped to this branch):
linz/basemaps@master...olitreadwell:basemaps:fix/landing-a11y-keyboard-controls
Or via CLI:
Prerequisites: none outstanding (re-verify CLA/DCO/signing before promoting).