Repository navigation
Return focus to the play surface when a clicked menu button unmounts - #2002
Merged
Merged
Conversation
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
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.
In Harbor Heat, WASD did nothing after clicking "Hit the street" until the player also clicked the canvas.
shell/playSurfaceFocus.ts: a capture-phaseclicklistener. Right after the click's update commits (setTimeout0, 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.GamePlayerShellinstalls 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 afocusout, 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— okplayer_pose(Report the local player's pose to drive RPCs #2001):BODY, position[-190, 1.2, 40]→[-190, 1.2, 40][-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