Skip to content

fix(a11y): return focus after dismissing map-screen reference-overlay error - #394

Open
luandro wants to merge 2 commits into
mainfrom
agent/comapeo-cloud-app/issue-390-focus-return
Open

luandro wants to merge 2 commits into
mainfrom
agent/comapeo-cloud-app/issue-390-focus-return

Conversation

@luandro

@luandro luandro commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #390

What

  • src/screens/MapScreen/MapScreen.tsx: dismissing the map-surface reference-overlay error (reference-overlay-map-error alert) no longer drops keyboard focus to <body>. The dismiss handler now calls requestAnimationFrame(() => mapPanelRef.current?.focus()), mirroring the idiom established in fix(map): restore authored layer error dismissal + maplibre-gl 6.x security upgrade #361 (AuthoredLayersControl.tsx).
  • Focus target: the map panel container div, given ref + tabIndex={-1} (programmatic-focus-only; not added to tab order). The MapLibre canvas is re-created by the map engine, so it is not a reliable programmatic focus target.
  • New regression test in tests/unit/screens/MapScreen/MapScreen.test.tsx (RED-first: verified failing pre-fix with activeElement === body), asserting focus lands on the map panel after dismissal.

Audit (per issue)

Review

  • Codex (gpt-6-astra) review: PASS, 0 P1/P2. One P3 (comment wording — canvas is focusable but unreliable as a target) applied verbatim in the amended commit. Reviewer's 3 local test failures were the known node-storage environment artifact; verified 36/36 green under Node 22.

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the focus-restoration behavior is narrowly implemented and covered by a targeted regression test.

Summary

This PR restores keyboard focus after dismissing the map-surface reference-overlay error.

  • Adds a stable, programmatic-focus-only map panel target.
  • Schedules focus restoration after the dismiss state update removes the alert.
  • Adds a regression test confirming focus returns to the map panel rather than the document body.

Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

… error (#390)

Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

React Doctor found 1 new issue in 1 file · 1 warning · score 91 / 100 (Great) · 1 fixed · vs main

1 warning

src/screens/MapScreen/MapScreen.tsx

  • ⚠️ L162 React function has high control-flow complexity no-high-complexity-react-function

Reviewed by React Doctor for commit 345923f. See inline comments for fixes.

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment ready: https://agent-comapeo-cloud-app-issu-vmlv.comapeo-cloud-app.pages.dev

Commit: b5feda1

This branch was successfully deployed

1 active deployment
preview — 345923f3 Deployed Sep 17, 2026 by github-actions[bot]
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.

a11y: dismiss button on map-screen reference-overlay error drops focus to body

1 participant