Skip to content

fix(controller): the D-pad's focus stays visible after a mouse click - #107

Open
lippdev wants to merge 1 commit into
fix/pointer-always-visiblefrom
fix/pad-focus-visible
Open

lippdev wants to merge 1 commit into
fix/pointer-always-visiblefrom
fix/pad-focus-visible

Conversation

@lippdev

@lippdev lippdev commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Stacked on #106.

Summary

Reproduced: after one mouse click (the + button, for example), the D-pad still moved the focus on the controller keyboard (q → w), but :focus-visible was false. The selected key stayed grey like the others, so the pad looked as if it no longer reached the keyboard. Chromium stops drawing focus moved by script once the user has used the pointer, and the pad moves focus by script.

  • gamepad.ts sets data-input="pad" on the shell's root whenever a button is pressed or a stick moves past the deadzone. A pointerdown or keydown removes it.
  • Every :focus-visible rule in shell.css and tokens.css gets a twin :root[data-input="pad"] …:focus. That covers the keys, the suggestions, the toolbar, the tabs and the menu.
  • The global ring skips tabindex="-1", so the keyboard dialog, which takes focus only to be announced, gets no outline around the whole window.

Test plan

  • npm run typecheck
  • npm test (118 passed)
  • npm run test:e2e (63 passed, 3 skipped), including axe on the shell. New regression test: mouse click on +, then D-pad right twice, and the focused key is lit both times. Before the fix it stayed grey.

🤖 Generated with Claude Code

The controller moves the focus by script, and once the mouse has clicked
anywhere Chromium stops drawing :focus-visible for that. On the keyboard
the D-pad then moved from key to key with none of them lit, so it looked
as if the pad no longer reached it.

The shell now marks data-input="pad" while the pad is in use (any button
or stick past the deadzone) and drops it on a click or a physical key.
Every :focus-visible rule of the shell and the design tokens has a twin
for :focus under that mark, so whatever the pad focuses is drawn: the
keys, the suggestions, the toolbar, the tabs and the menus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant