Skip to content

Return focus to the play surface when a clicked menu button unmounts - #2002

Merged
Noisemaker111 merged 2 commits into
betafrom
reclaim-focus-removed
Oct 20, 2026
Merged

Noisemaker111 merged 2 commits into
betafrom
reclaim-focus-removed

Conversation

@Noisemaker111

Copy link
Copy Markdown
Owner

In Harbor Heat, WASD did nothing after clicking "Hit the street" until the player also clicked the canvas.

  • shell/playSurfaceFocus.ts: a capture-phase click listener. Right after the click's update commits (setTimeout 0, not a frame callback, so it doesn't stall on slow frames), it focuses the play surface if the clicked element has unmounted and focus fell to <body>. A click whose element still exists, or one where something else took focus, is left alone.
  • GamePlayerShell installs it (not for posters). 4 tests on the decision; changes/reclaim-focus-removed.md.

Root cause: gameplay keys are read on the shell's focusable wrapper. Chromium moves focus to <body> when the focused button is removed, without a focusout, so the keys never reach the wrapper. Deepward works around it in game code (grab() refocuses the canvas after every menu button); other games just look stuck.

Verification

  • bun test packages/shell/src/playSurfaceFocus.test.ts — 4 pass, 0 fail; check-types — pass; bun run gen — ok; ship:preflight — ok
  • Live, Harbor Heat, same probe on each build: click "Hit the street", hold W 20 s, read player_pose (Report the local player's pose to drive RPCs #2001):
    • without this PR: active element BODY, position [-190, 1.2, 40] → [-190, 1.2, 40]
    • with it: active element the play surface, position [-190, 1.2, 40] → [-189.432, 1.2, 38.625] (headless runs about 0.2 fps, so the distance is small)

No rendered surface changed.


Generated by Claude Code

Gameplay keys are read on the shell's focusable wrapper. Clicking a start
button that unmounts left focus on <body>: in Harbor Heat, 20 s of held W
after 'Hit the street' moved the player 0 m until the canvas was clicked.
Deepward worked around it by refocusing the canvas in game code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RwsemkhoUGyeQkdkKFmUmw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RwsemkhoUGyeQkdkKFmUmw
@Noisemaker111
Noisemaker111 merged commit 7d5e35f into beta Oct 20, 2026
6 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.

2 participants