From e06600afe1b8aed238c7b597f89797a8546b2752 Mon Sep 17 00:00:00 2001 From: Lotus CI Date: Thu, 24 Sep 2026 11:02:46 -0400 Subject: [PATCH] fix(a11y): Escape no longer yanks focus into the composer (#187 DP9) RoomView focuses the composer on any "typing" key pressed while nothing editable has focus, and Escape counted as typing. Closing the GIF picker with Esc (its focus trap returns focus to the GIF button) therefore landed in the composer instead, and so did Esc on any other room control. Escape, CapsLock, Insert, ContextMenu, PrintScreen and Pause are now excluded like the other non-typing keys. Verified at 1300 px and 320 px: Esc closes the picker and focus is back on "Insert GIF"; the 320 px picker fits with no page overflow. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA --- src/app/features/room/RoomView.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/features/room/RoomView.tsx b/src/app/features/room/RoomView.tsx index 57acb73aa..a07fa6077 100644 --- a/src/app/features/room/RoomView.tsx +++ b/src/app/features/room/RoomView.tsx @@ -51,7 +51,17 @@ const shouldFocusMessageField = (evt: KeyboardEvent): boolean => { code === 'Space' || code === 'Enter' || code === 'NumLock' || - code === 'ScrollLock' + code === 'ScrollLock' || + // Not typing: Escape in particular dismisses popouts, and a focus-trap + // hands focus back to the opener on Escape. Treating it as "start typing" + // yanked focus into the composer instead (#187 DP9: closing the GIF picker + // with Esc left focus in the composer, not on the GIF button). + code === 'Escape' || + code === 'CapsLock' || + code === 'Insert' || + code === 'ContextMenu' || + code === 'PrintScreen' || + code === 'Pause' ) { return false; }