Skip to content

Keep keyboard focus inside the tutorial overlay - #232

Merged
acrosman merged 1 commit into
mainfrom
fix/221-tutorial-overlay-focus-trap
Oct 18, 2026
Merged

acrosman merged 1 commit into
mainfrom
fix/221-tutorial-overlay-focus-trap

Conversation

@acrosman

Copy link
Copy Markdown
Owner

Fixes #221

Change

The tutorial overlay has role="dialog" and aria-modal="true" but did not trap focus. Tab could reach the page behind it. Now, while the overlay is open, tutorialService.js makes the rest of the page inert and aria-hidden, as the History modal does. The overlay sits inside the game container, so the service marks the siblings of the overlay and of each of its ancestors up to <body>, not only body > *. Closing the overlay undoes only what it changed and returns focus to the control that opened it. All four ways the overlay closes (finish, skip, Start Practice, cancel) go through one close function.

Testing

  • 7 new tests in tutorialService.test.js; 5 of them fail on main. Lint is clean, and npm run test:coverage passes (2124 tests).
  • Checked in the running app with Playwright and an isolated --user-data-dir. In Fast Piggie, Tab and Shift+Tab now cycle only between Next and Skip Tutorial. The page is fully restored after Skip and after Start Practice, and the practice coach takes focus.

After Skip, focus still lands on <body>, because starting the session hides the welcome panel. That is #222 and is not changed here.

Signed: Claude Code (Claude Opus 5.5) for Aaron Crosman

🤖 Generated with Claude Code

The tutorial overlay said it was a modal dialog but did not contain
focus. Tab from Skip Tutorial reached the shell's skip link and the
game's welcome buttons behind it, which could be activated.

While the slides are open, the rest of the page is now inert and
aria-hidden, as the History modal does. The overlay sits inside the
game container, not under <body>, so the siblings of the overlay and of
each ancestor up to <body> are marked. Closing restores only what was
changed and returns focus to the control that opened the tutorial.
Every path that removes the overlay (finish, skip, Start Practice,
cancel) goes through one close function.

Fixes #221

Signed: Claude Code (Claude Opus 5.5) for Aaron Crosman

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@acrosman
acrosman merged commit 38cadfd into main Oct 18, 2026
7 checks passed
@acrosman
acrosman deleted the fix/221-tutorial-overlay-focus-trap branch October 18, 2026 19:56
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.

Tutorial overlay lets Tab focus escape to the page behind it

1 participant