휴대폰에서 채팅을 보낸 뒤에도 키보드 유지: "보내기" 버튼을 누르면 포커스가 버튼으로 넘어가 입력 칸이 빠지고 키보드가 내려가던 것을, 버튼의 pointerdown/mousedown 기본 동작을 막아(lib/chat-input keepFocus) 포커스를 입력 칸에 두고, 보낸 뒤에도 입력 칸에 포커스를 다시 줌. 방 채팅(ChatPanel)·그림 맞히기·마피아·라이어 게임 채팅 모두. Esc로 빠져나가기와 포커스가 빠질 때 "입력 중" 끄기는 그대로. chat.e2e.ts(휴대폰 시트에서 보내기 탭)와 games.e2e.ts(catchmind·mafia·liar 보내기 버튼)에 확인 추가, docs/07에 한 줄

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-15 10:25:06 +09:00
parent b61be627c9
commit 57351fd9d6
8 changed files with 58 additions and 12 deletions

View File

@@ -4,8 +4,10 @@
* Chat lines are sent the moment Enter is pressed — no queue and no pace limit.
* - `useTypingSignal`: tells the others "입력 중" while there is text in the box (renewed every 2 s, cleared when the
* box is emptied or the line is sent, and when the box goes away).
* - `keepFocus`: props for the send button so pressing it leaves the focus in the chat box — on phones the keyboard
* stays up after sending, like with the keyboard's own send key (catchmind uses it too).
*/
import { useCallback, useEffect, useRef } from 'react';
import { useCallback, useEffect, useRef, type SyntheticEvent } from 'react';
import { socket } from '../net/socket';
const RENEW_MS = 2000;
@@ -36,3 +38,7 @@ export function useTypingSignal(ch: 'room' | 'game', enabled = true) {
useEffect(() => stop, [stop]);
return { onText, stop };
}
/** Spread on a chat form's send button: pressing it doesn't move the focus off the input (the phone keyboard stays up). */
const noFocus = (e: SyntheticEvent) => e.preventDefault();
export const keepFocus = { onPointerDown: noFocus, onMouseDown: noFocus };