mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-10 01:09:43 +02:00
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:
@@ -677,6 +677,16 @@ Object.assign(CodemanApp.prototype, {
|
||||
this.closeTileCountMenu();
|
||||
}
|
||||
};
|
||||
// The keyboard leaving the menu for something else closes it, as any menu:
|
||||
// closing the grid starts a selection that focuses the single view's
|
||||
// terminal when its replay lands, and a menu left open behind that would
|
||||
// send the keys meant for it (arrows, Enter, Escape) into the terminal. A
|
||||
// focus going nowhere (a click on a button in Safari, which does not focus
|
||||
// it) does not count.
|
||||
menu.addEventListener('focusout', (e) => {
|
||||
const to = e.relatedTarget;
|
||||
if (to && !menu.contains?.(to)) this.closeTileCountMenu({ refocus: false });
|
||||
});
|
||||
this._tileCountMenu = { menu, onOutside, onKey };
|
||||
document.addEventListener('click', onOutside);
|
||||
document.addEventListener('keydown', onKey, true);
|
||||
|
||||
Reference in New Issue
Block a user