fix(tiles): the count menu closes when the keyboard leaves it

Found live: closing the grid with a click starts the single view's
selection, which focuses its terminal when its replay lands, a few
hundred milliseconds later. A right-click on Tiles in between opened the
count menu with the keyboard in it, and the late focus then moved the
keyboard into the terminal while the menu stayed open (3 of 3 tries), so
the arrows, Enter or Escape meant for the menu went to the session's
PTY instead (an Escape arrived there as an ESC byte).

The menu now closes when the keyboard leaves it for another element, as
any menu does. A focus going nowhere (a click on a button in Safari,
which does not focus it) does not count, so a click on a count still
picks it. Live afterwards: the menu either closes as the terminal takes
the keyboard, or keeps it when the replay landed first; never open with
the keyboard elsewhere.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer
2026-10-08 05:13:43 +02:00
parent 4ad283c647
commit fcec77131c
4 changed files with 32 additions and 2 deletions
+3 -1
View File
@@ -59,7 +59,9 @@ or settled a question the spec left open. The invariants as built are in
Shift+F10 and the Menu key open it too (the browser's contextmenu event). Arrows move
over the counts that fit, Enter or Space picks, Escape closes it alone (the global
Escape handler gives it the key first, like the tab-group menu) and puts the keyboard
back on the Tiles button, Tab and a click elsewhere close it. A pick is remembered per
back on the Tiles button, Tab, a click elsewhere and the keyboard leaving it for another
element close it (the single view a close starts focuses its terminal when its replay
lands; a menu left open behind that would send its keys there). A pick is remembered per
device in `codeman:tile-count` (`codeman:tile-grid` stays ids only) and opens that many
tiles; with the grid open it re-forms it (`_reformTileGrid`): the focused tile always
stays, the others leave from the end or join from tab order, filling empty cells first,