Skip to content

Clicked chrome releases the keyboard back to the editor - #81

Merged
rebaserHEAD merged 2 commits into
mainfrom
fix/click-focus-steal
Jul 28, 2026
Merged

Clicked chrome releases the keyboard back to the editor#81
rebaserHEAD merged 2 commits into
mainfrom
fix/click-focus-steal

Conversation

@rebaserHEAD

Copy link
Copy Markdown
Owner

About

Field report: toggle a layer checkbox, then keybinds stop working. Space toggles the checkbox again, arrows navigate the panel, and tool shortcuts (like the entity editor) go dead until you click the canvas.

This is stock browser behavior: a click moves DOM focus onto the control and leaves it there, and the keyboard hook correctly refuses to fire shortcuts while focus sits in a form control. Webapp behavior, exactly the kind we keep hunting down.

Rather than patch the Layers panel and leave the same trap in every other panel, this adds one app-wide guard: after a click lands on click-activated chrome (buttons, links, checkboxes, radios), focus is released back to the document, so the keyboard belongs to the editor again. Three deliberate carve-outs:

  • Text fields, selects, sliders, and color wells keep focus. Typing or arrowing in those is the point.
  • Tabbing to a control still works. The guard only reacts to clicks, so keyboard accessibility is untouched.
  • A click handler that deliberately focuses something else wins (the search bar clear button refocuses the search input; the guard checks what is focused after the handler, not what was clicked).

I checked first that nothing relies on blur-to-close: the only onBlur users are the commit-on-blur text fields in Map Properties, which are text inputs and exempt.

Testing

  • 17 new tests: checkbox/button release focus, text/select keep it, refocus-during-click wins, teardown on unmount, and the classifier table for every input type.
  • Full suite 961 passing, typecheck clean.

Checklist

  • Changelog updated
  • Tests pass

Clicking a button or checkbox left browser focus on the control: Space
re-toggled the layer checkbox instead of panning, arrows walked the
panel, and every editor shortcut died on the useKeyboard input guard
until the canvas was clicked.

Add an app-wide guard that blurs click-activated chrome (buttons, links,
checkboxes, radios) after the click lands. Controls where post-click
typing is the point (text fields, selects, sliders, color wells) keep
focus, and keyboard-driven focus is untouched because the guard only
reacts to clicks. A handler that deliberately moves focus during the
click (the search clear button) wins over the guard.
@rebaserHEAD
rebaserHEAD merged commit 109ba66 into main Jul 28, 2026
1 check passed
rebaserHEAD added a commit that referenced this pull request Jul 28, 2026
Merged main in (PR #81, chrome focus-steal fix) so the branch lints the
same tree CI does; the new test file had one `as string` on a value
already typed string, which the type-aware lint flags.
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